Override `process.exit` to give some context when it's called unexpectedly in a test.
Just had an issue on Gitter where a users code was causing process.exit(1) to be called. He got the "test.js exited with a non-zero exit code message", but there was no helpful information.
I say we try and capture that somehow:
var oldExit = process.exit;
process.exit = function (code) {
if (code > 0) {
var stack = new Error().stack;
// log it? send it to parent?
// ...
}
oldExit.apply(process, arguments);
};
There is a $60.00 open bounty on this issue. Add more on Issuehunt.
- Checkout the Issuehunt explorer to discover more funded issues.
- Need some help from other developers? Add your repositories on Issuehunt to raise funds.
Shouldn't we log no matter what the code is?
People should not be calling process.exit() in tests at all.
Oh, yeah. That's definitely true
I brought this up on Gitter, what tripped me up was a function that checks that all the needed dependencies are installed exits with 1 if one is missing, which means it will exit with 1 on Travis but not locally, and I didn't think of this. However, as you mentioned, it shouldn't run in tests so I've fixed it by now. So yeah, it was a case of PEBCAK.
@issuehunt has funded $60.00 to this issue.
- Submit pull request via IssueHunt to receive this reward.
- Want to contribute? Chip in to this issue via IssueHunt.
- Checkout the IssueHunt Issue Explorer to see more funded issues.
- Need help from developers? Add your repository on IssueHunt to raise funds.