-
-
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
No way to fix tests from hanging with fake modern timers #11572
Comments
I'm facing the same issue using modern timers and cache-manager. Here is a repo for reproducing it: https://github.com/fstoerkle/jest-modern-timers-cache-manager |
Hit a similar issue after upgrading from jest 26.6.3 to 27.2.1. We have
But didn't really appreciate what that would mean or how it breaks with existing usage of |
I ran into this issue trying to migrate from manually using |
Fixed via #12572 by using |
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. |
🐛 Bug Report
Using some nodejs libraries in source code (e.g. fast-glob) and modern timers leads to hanging tests with the error
Exceeded timeout of 5000 ms for a test
.I've tried different things to force timers to continue executing (e.g.
jest.runAllTimers()
,jest.runAllTicks()
) but nothing helped.Also changing timers type on file level (e.g.
jest.useRealTimers()
andjest.useFakeTimers('legacy')
) doesn't prevent test from hanging - only changing timers type injest.config.js
to real or legacy fixes it.To Reproduce
You can find reproduction steps in repo
I think issue is coming from the usage of
setImmediate
inside some of the dependencies, but I have no idea why it is not resolvable by any of jest's functions for timers.Expected behavior
There should be a way to prevent the test from hanging, at least changing timers type at file level should work the same way as it working on config level.
Link to repo
https://github.com/meskill/jest27-fake-timers-hangs
envinfo
The text was updated successfully, but these errors were encountered: