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
Running global jest-cli
should warn instead of error
#1293
Comments
Thank you for bringing this up and for the detailed description of the issue. To be honest, I have been upset about this stuff myself and it definitely makes Jest's test suite a little harder to deal with. I also agree the way this is working currently does not make any sense if Jest still ends up running tests anyway. I'm sorry you wasted time on this. Would you be willing to send a pull request? My suggestion is as follows:
It will allow people to use the wrong version of Jest (which isn't recommended, because there might be breaking changes) but it will still finish the test run properly and will print a message at the bottom. What do you think? |
@cpojer That works for me, thanks for the quick response! Will submit the PR shortly |
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. |
The
process.exit(1)
call triggered when running a globally-installed version of Jest results in odd test results - even when all tests pass, the process returns a non-zero exit code, and it's not immediately clear why.When
jest
is assigned tonpm test
(which is a pretty common convention), you get:There are no obvious details (the "Please run..." line doesn't look like an error message") and no failing tests, so debugging is awkward.
Recommendations
getJest
entirely. If people want to use a non-local version of Jest without runningnpm install
, I'm not sure why the package should care?console.warn
without affecting the exit code because the tests may still run without trouble, and the warning is sufficient indication that the output might not reflect exactly what the user intended.Error
to make debugging easier - Node's built-in error handling is much more explicit thanconsole.error
followed byprocess.exit(1)
.process.exit(1)
immediately rather than waiting for all the tests to run - if it's not okay to run Jest globally when there's a missing locally-defined dependency, then it shouldn't run at all.The text was updated successfully, but these errors were encountered: