-
-
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
With modern fake timers, an infinite loop contaminates all following tests #10357
Comments
@SimenB is this issue relative! can i consider it as "good first issue" ? try to work on it! |
The first test simply throws: 'Aborting after running 100000 timers, assuming an infinite loop!' But before throwing it still calls All gets solved if fake timers are reset in the second test: jest.useRealTimers().useFakeTimers("modern").runAllTimers(); Alternatively, one could use afterEach(() => {
jest.clearAllTimers();
}); Or to reinstall fakes: afterEach(() => {
jest.useRealTimers();
}); Hm.. Perhaps before throwing it is possible to clean up a timer causing infinite loop in Sinon's Fake Timers? But what if there is another timer which will cause infinite loop soon after the error? That’s complicated. Looks like it is better to clean up manually between tests. |
I don't think we should automatically clean up timers between tests, that's up to the author |
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
Test cases that fail due to excessive timer recursion can cause failures in following tests, as the infinitely-recursing timer is not cleared between tests.
Jest version: 26.2.2
To Reproduce
Expected behavior
Despite the first test failing, the second ought to be green.
Observed behaviour
The second test fails due to timer recursion.
Adding
clearMocks: true
andresetMocks: true
doesn't help matters.The text was updated successfully, but these errors were encountered: