Closed m90 closed 2 years ago
On a meta level I was surprised to find that @mochify/mochify
sets process.exitCode
on test failures which I wouldn't expect from an API module. Should it maybe rather throw in such cases, leaving it up to the consumer to define how this should affect the program?
On a meta level I was surprised to find that @mochify/mochify sets process.exitCode on test failures which I wouldn't expect from an API module.
Indeed, I agree.
Should it maybe rather throw in such cases, leaving it up to the consumer to define how this should affect the program?
It could also return { exit_code }
, which could be assigned to process.exitCode
in @mochify/cli
.
Closing this in favor of #260
It could also return { exit_code }, which could be assigned to process.exitCode in @mochify/cli.
I like this because a failed test run is not really a runtime exception so it's still possible to distinguish the two.
As described in #258 a failed bundling would currently cause Mochify to never exit (when using
driver-puppeteer
at least).This seems to happen because in that case noone ever calls
end
on the driver, leavingpuppeteer
idling. To work around this, we can make sure bundling worked properly before instantiating the driver so we can make sure it can always be closed.N.B.: In case you are wondering how it would look like if bundling and driver instantiation would still happen in "parallel": https://github.com/mantoni/mochify.js/commit/279086018643a9f98b54f975607ba3aeb4514217 - I found it nicer doing it serially as it requires a lot less control flow logic.