-
-
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 #3893
Comments
I've been going through test combinations trying to pin stuff down, I currently have a it blocked to a set that seems to return a proper exit code or not on a whim. Same set of tests, same environment, one run I'll get 0 (incorrect) the next I'll get the error count exit code (expected). |
Appreciate your efforts thusfar, but without an MCVE there's not much we can do. You also seem to have quite the stack there, which needs to get paired down to just Mocha; we |
I understand, and if I can pinpoint a reliable MCVE I'll post one, it's just taking a while to whittle things out. As a clarification, the environments listed were multiple envs and tools checked to eliminate that as the root cause. |
Please try to run your tests - instead of |
@juergba, "<project>/node_modules/.bin/mocha" is same thing as "mocha/bin/mocha". |
@nwesterman, do your failures repeat to same test case(s)? Are the failing cases async-related? Are you stubbing |
I was able to get a subset of tests arranged that I'm free to upload, and reproduce the issue. This specific arrangement has been giving me an exit code of If it does not reproduce on other systems I likely trimmed too much, since the sheer number of tests & time to run them seems to affect reproducability (this has been true for awhile, and is likely why upgrading node in the past helped, as the runtime improved). Tests Files are numbered to mess with run order. https://github.com/nwesterman/mochaExitCode_3893
@plroebuck The assertions pass/fail as I would expect. Some of the assertions in our project are in async tests, but none of the ones in the posted subset do. We do not stub
@juergba I did not notice any difference besides the test runtime not printing (e.g. Done in 4.45s) using Our current work around to this issue is running files separately as its only when we run a significant number at the same time that the error occurs. When run alone each suite works as expected. |
Any updates here? Did you review my results? |
Created a gitlab CI, succeeded like your run. Duplicated a number of the tests, have it reproducing. |
Still WOMM. Same steps as before. Results from GitLab repo. Now reports 19 errors instead of 12. $ node --version
v10.15.0 |
Between running node 10 and your computer resources, the test set run faster and complete. Which is why I pushed everything up to Git to run with their CI for reproducability. Also pushed your organization changes off a branch and onto master. |
Nit: package.json "test": "mocha './{,!(node_modules)/**/}*.test.js'", to "test": "mocha", |
Nit: README.md Run command: `$ ./node_modules/.bin/mocha` |
So if I understand you, this problem only happens if your ".gitlab-ci.yml" uses Where would you like to go with this now? I'm not going to trawl all the possible changes across major Node versions (and affected packages). |
Trawling node versions doesn't change anything its a band-aid over the problem. The previously "resolved" ticket was on node 7.2, and our group has seen the issue from node 8 up through node 12 Node 10 branch: https://gitlab.com/nicwest/mochaexitcode_3893/tree/node10 Only additional change from the node 8 branch, repeated tests to extend the run. I'd created master on node 8 to reduce the code needed to reproduce the issue. |
This happens with cypress. Reproduction steps.
I found this bug because it happened in cypress CircleCI. Check cypress-io/cypress#5770 |
@nwesterman It seems to be a reporter problem. First I removed the
The warnings disappear, but still the tests don't run completely. When I use a different reporter like "json" or "min", then the tests seem to run successfully to the end with exitCode 19. |
Prerequisites
faq
label Applicable issue Mocha exits with 0 exit code with failing tests #2713 is closednode node_modules/.bin/mocha --version
(Local) andmocha --version
(Global). We recommend that you not install Mocha globally. not installed globallyDescription
Mocha exits with exit code 0 despite having failing tests
Visually confirmable by truncated output. Does not print all test lines before printing Done in x. Last test line printed varies run to run.
Steps to Reproduce
Working to determine outside of our test suite. Running sub-suites alone seems to work fine, but running the entire suite does not. Possibly a timing or issue with high test counts?
Expected behavior:
Mocha reports a non-zero [success] exit code
Actual behavior:
Mocha reports a 0 exit code and does not complete console output.
Test Output
Reproduces how often:
Currently, every time I run the full suite. This has been a recurring problem for us, sometimes upgrading node has helped, but have not found a solution this time, most likely was a bandaid for the problem.
Versions
Mocha: 3.5.3 and 6.1.4
Node versions 8.10, 8.11, 8.12, 8.16, 10.0, 10.16 (In the past upgrading node 8.9 to node 8.10 seemed to fix, but no longer is a solution)
Gitlab runner: docker:latest node:8
Ubuntu 16.4 64bit
Windows 10 64bit - Git bash MINGW64 & Windows powershell
##Related Issues
#2713
#188
#187
#2438 (comment) in discussion, not main post
The text was updated successfully, but these errors were encountered: