I've tried to run Node.js tests and I expected my app to close itself when those are done, but instead the app continues to run.
I read about the --test-force-exit
flag for Node.js in its issue and I saw that it was implemented. I'm trying to use it for my project, but it seems to not work.
I've tried to run my tests like so:
node --test test/**/*.test.js --test-force-exit
but the app is still running when the tests are done.
I know that I can pass an argument to the run()
function, but I'd like to run it directly from command line.
Am I doing something wrong with the command?
After further tests, I found out what was wrong in the line above: it was executed all until the pattern. For whoever will need it, to have the desired behaviour I ultimately used this code inside my package.json:
"scripts": {
"test": "node --test --test-force-exit --test-name-pattern='.*\\.test\\.js'",
},
That it results in
node --test --test-force-exit --test-name-pattern=".*\.test\.js"