-
-
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
[Bug]: uncaught async error crashes jest --watch #13996
Comments
I am facing a similar issue where the Jest Crashes with an error |
@benjaminjkraft This is expected behaviour. You should look through the The test case in your reproduction throws when the test run is already finished. Jest should crash, because something fatal happened. That test simply should not pass. You should await the promises, mock timers, catch errors inside a test. If something throws outside of any test, this is considered fatal. |
I understand that I'm supposed to await promises. I nonetheless find this frustrating because it means watch mode is useless if I am debugging why the test is not correctly awaiting its promises! And I find it a bit confusing because if I run multiple tests (and thus, I'm guessing, multiple workers) in watch-mode the test will actually pass (with a warning about open handles). I guess what you are saying means the fact that it doesn't crash in that case is a bug? |
Ah.. Looks like I misunderstood the problem, open handles is different case. I copied you the test case from your repo into larger code base. Jest crashes with This can be solved by tweaking Thanks for more details. I think the behaviour should be more predictable. |
The comment here already said one good reason to do this; another is that if the test hard-crashes (e.g. an async error after it completes) then using workers allows us to still watch for changes (perhaps to fix that crash). So now we just always use workers in watch mode; this probably worsens startup time slightly but for watch mode that's hopefully not as much of a problem. Fixes jestjs#13996.
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. |
Version
29.5.0
Steps to reproduce
jest --watch <test file>
.Repro repo here, run
npx jest --watchAll
and wait 1s.Expected behavior
I expected Jest to report the failure, but continue in watch-mode.
Actual behavior
Jest crashes and doesn't continue to watch.
Additional context
Seems to only happen when running just one test file, so I'm guessing it has to do with tests that run in-band instead of in a worker?
Environment
The text was updated successfully, but these errors were encountered: