-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mocha exits with 0 exit code with failing tests #2713
Comments
I added some tracing statement to the code as follows and see the following output:
Results in:
|
Proposal: eagerly set the |
* Eagerly set the process exitcode in case the write callback isn't executed before the process terminates. * Remove the extraneous call to `done()` at the bottom of the function. * Cleanup the `draining` reduction and value check in `done` into separate lines for easier reading.
Fix for issue mochajs#2713
FWIW, I'm also able to reproduce this in a Linux container running on CoreOS with the same Node and Mocha versions and same test. |
Running into this issue on our CI running on Travis. Tests fail, but Mocha exits with |
Simpler version of PR mochajs#2714 which only eagerly sets the exitcode without playing with the draining semantics
The Sorry it took long! |
I'm using mocha 5.0.1 and it does not exit with an error code if tests fail... I had to use a hacky workaround for this to make it work in travis.
(yarn test executes mocha) |
@olastor |
I'm still seeing this happen in mocha 3.5.3 and 5.1.1 |
I'm seeing this behaviour in mocha 5.2 but only with my integration tests, which use I'm refactoring my integration tests now to eliminate the need for this package. |
my guess is that the exit codes are somehow tied to the reporter that is being used. try switching out the reporter and see if that changes the exit codes |
I saw this on node 8.9 and it resolved itself going to node 8.10 |
This has been a continuous problem for us. Updating something (like node 8.9->8.10) will seem to fix it and then it spontaneously appears again. I'm seeing this happen with 3.5.3 and 6.1.4 on numerous Node versions 8.10, 8.11, 8.12, 8.16, 10.0, 10.16 (haven't found a working combination yet). Observed on both linux and windows OS. In addition to our gitlab-ci pipeline not failing, I can visually see the output not completing in the console log. Tests lines at the end don't print nor do the error details. Running just the failing suite does cause the exit code to print, but running the entire suite does not. Possibly a timing or issue with high test counts?
|
@nwesterman, this issue is closed. If you're having problems, open a new issue with an MVCE. Since you said output was abbreviated, can't tell whether you only SNIP'd from top, or between "Parses hex" and "Done in 5.67s". |
Node: 7.2.1
Mocha: 3.2.0
MacOSX: Sierra (10.12.3)
Cmdline:
mocha my_test.js
Seeing mocha exit with a 0 exit code after failing a test in an
after each
hook. I traced it down to this code:mocha/bin/_mocha
Line 425 in 9ae6a85
The function is called with the correct exit code, but then
stream.write('', done);
doesn't call the callback before the process terminates.The text was updated successfully, but these errors were encountered: