-
-
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: resetAllMocks
messes up runAllTimers
when using useFakeTimers
#5371
Comments
In your code you've called the If you replace that with Do you really require it to be |
Yes, the current workaround is to If I understand correctly, So, the expected behavior would be to run This is also based on what we see in the docs: If the docs would have noted to run it on |
@SimenB would you suggest updating the docs or looking into this particular issue? |
@SimenB haven't thought about that either. Would be quite a breaking change with Lolex. |
FWIW I've set up the Lolex branch to spy on the methods, so no longer breaking in that regard |
My current thinking is that we should remove the mocks from the timing functions when using fake timers. Easy enough for people to do |
it’s a surprise to me that |
This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days. |
Modern timers (available jest 26, default jest 27) are not affected by this. PR welcome documenting this for legacy timers, tho |
@SimenB I would love to give it a try. Can I handle this ? |
I would love to give it a try. Can I handle this ? |
I would like to work on this issue |
bug: resetAllMocks messes up runAllTimers when using useFakeTimers jestjs#5371
This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days. |
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
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?
When using
useFakeTimers
, runningresetAllMocks
messes uprunAllTimers
in the second test (it does not advance the timer) and the test times out (fails).If the current behavior is a bug, please provide the steps to reproduce and
either a repl.it demo through https://repl.it/languages/jest or a minimal
repository on GitHub that we can
yarn install
andyarn test
.https://repl.it/repls/CarelessNormalAssassinbug
What is the expected behavior?
resetAllMocks
should indeed reset thecalls
instances of thesetTimeout
mock, butrunAllTimers
should still work as expected and complete thesetTimeout
Please provide your exact Jest configuration and mention your Jest, node,
yarn/npm version and operating system.
Jest v22.1.4
Node v9.3.0
Yarn v1.3.2
Mac OS X 10.12.6
The text was updated successfully, but these errors were encountered: