Is there a reason why the IFX Node SDK auto-writes the eventsHandler module? This functionality has proven to be a bit of a thorn in my side for the following reasons...
It generates code that breaks linting rules I have established. The module.exports object does not end with a semicolon, and the file does not end with a new line. I have to either exclude the file from linting checks, or continually git restore
it during development.
It is not compatible with same-folder testing architecture. If I have a defaultHandler.test.js
file in the eventsHandlers
folder, the eventsHandler.js
file is generated with malformed javascript:
const defaultHandler = require('./eventsHandlers/defaultHandler');
const defaultHandler.test = require('./eventsHandlers/defaultHandler.test');
module.exports = { defaultHandler, defaultHandler.test }
In addition, the autogeneration of this particular file is not immediately obvious, so I spent quite some time confused why it kept changing on me. The generated code seems quite simple, so I don't understand what purpose autogenerating it really serves.
Most welcome!
Hi Bridgette, thank you for the helpful responses. Given the clarification on where tests can live in the codebase, I've decided to simply exclude the file from linting checks. Thank you for looking into this for me, and thanks for the engineering team for the detailed answer.
I got more information:
After the script generates the
eventHandlers.js
file for the first time, they can remove theprelocalTestingServer
andpostinstall
scripts frompackage.json
to prevent overwriting that file. Moving forward, they will just need to add any new handler files to the previously generated file so that the SDK can locate them at runtime.I'm not as familiar with this as my engineering team, so I asked them. This was their response:
Is this helpful?
Hi Bridgette, thanks for responding. I am not sure what files you are referring to, could you be more specific?
Hi Lowell, sorry to hear about this frustration. I will add this to our team's agenda for discussion. Are you aware that you can delete those files and all references to them?