-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
The cli doesn't exit correctly when stdout is a non-tty #5332
Comments
I assume you mean versions 22.1.0 and 22.1.1. cc @mjesun |
I've been able to repro; I'm checking it. |
@thymikee you are 100% correct 😉 I updated the original comment |
@szeller can you test with 22.1.2? |
@SimenB it's still broken in that version for me |
I can confirm that I have the same problem |
Can you create a repro? |
I've been able to repro it internally with a parent project that excludes files of a child project. I'm fixing it by re-running the testPattern function on every file, even if the file exists, and even if it is on the root of the Haste instance monitoring the project root folder. I should have something soon as a PR. |
@mjesun release 22.1.3 doesn't fix this one for me |
Then we're going to need a minimal repro test case; I can't see any other issues with the internal configs 😔 |
Okay. I'll look at trying to create a minimal test case for it. |
I made a test case repo for this one https://github.com/szeller/jest_failure_bug In order to reproduce, you need to use AWS codebuild using the default node 6 build. Since there's a failure in one of the tests, the build should fail (and does fail on jest 22.1.0) but won't fail on jest latest |
Thanks @szeller! I will try looking at it through the day. This should definitely make debugging easier. What is the test that should fail? |
NVM, i fully checked the project and saw there's only one 😄 |
@mjesun like I said in the original description, everything works fine on my local machine. On both codebuild and locally, the test output is more or less the same. However, on codebuild, the My guess is that it's not so much codebuild specific as it is specific to some part of the codebuild env: docker, using sh vs bash, non-tty, returning true from https://github.com/watson/is-ci, etc |
I did some more testing and was able to reproduce the issue locally. It looks like the problem is that the exit value is always 0 if stdout is not a tty. e.g. if you do |
Hopefully the latest edits to the title and description clarify this one. It feels like this is pretty major regression and I'm surprised that more people haven't reported it. That said, I tried running the tests via jenkins and the build failed as expected so there's definitely some scenarios where it works fine. |
I can confirm we are experiencing the same issue, all great locally but on Jenkins a failed test run exits with |
It looks like it's due to the This should only happen on asynchronous stdout/stderr streams. |
@lsjroberts For us, |
@dcarrot2 Did you do both |
@mjesun any ETA on a fix? This one feels fairly critical since it's allowing build systems to ignore test failures. |
Experiencing this on Jenkins as well. Even with |
Unfortunately we already rely on this at FB actually. Would a possible fix be to set |
@cpojer Yeah I believe that would fix it, thanks. I was under the impression using I'm sure there was a reason |
I see the problem even at the command line locally, 21.2.1 exits properly:
22.0.0 is when it started failing to exit properly (and it doesn't even seem to catch its own errors, I can't show the full error, but here is what I can show):
|
@markFromMST I think that's potentially a different problem. For the one that I'm encountering, the failure count is always correct and the exit value is the only thing that is wrong |
Removing all The only change done lately to exit codes is in #5313, but the change was pretty straightforward. Plus, the It's quite interesting that this only happens when the output is not a TTY, essentially because that's the default for integration tests. I will try investigating it tomorrow, sorry for the inconvenience. |
@mjesun I agree that PR #5313 was fairly straightforward but that's the commit that caused the problem that I'm referencing 😉 You can test that my test repo works fine with the release previous to that change and fails using the version with that PR in it. It looks like there are some odd issues on some platforms with exit that were never fixed. It sounds like something similar to the bug that we're seeing here. cowboy/node-exit#7 |
What is the package version for jest and jest-cli to fix it. For me, all test pass case not exiting. :/ |
The fix is available in 22.2.0 and newer |
I'm using jest 24.9.0 and seeing the same issue, i'm not seeing exit code 1 with failure (i'm using AWS codebuild for CI) Anyone has the same issue anymore? |
Same issue with jenkins and jest 24.9.0 |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
If you are redirecting stdout to a file (or have stdout not connected to a tty in a similar way), then the jest-cli process will exit with 0 even if there are failing tests. If you execute jest from the cli without any kind of redirect in place, then you get a non-zero exit value for failing tests as expected.
It appears that this was introduced with the exit changes in this PR #5313
What is the expected behavior?
A non-zero exit value in the case of test failures.
Please provide your exact Jest configuration and mention your Jest, node,
yarn/npm version and operating system.
NOTE I updated the description since the original bug report with my latest findings
The text was updated successfully, but these errors were encountered: