-
-
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
jest.useRealTimers() has no effect #3815
Comments
Maybe related to #3814 |
describe('foo', () => {
beforeEach(() => jest.useRealTimers());
it('bar', () => {
jest.runAllTimers();
});
});
|
Discard my previous comment, I haven't read your final thoughts. PR is on it's way :) |
No worries! Thanks for looking at it @thymikee 😊 |
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. |
When
timers
is set tofake
in Jest configuration, top level calls touseRealTimers
have no effect on the test behavior. Files to reproduce:Given the following
package.json
file:And the following test:
You can observe how executing this test will not throw any warnings on calling
runAllTimers
with (supposedly) real timers enabled. This is due to the fact that, after executinguseRealTimers
at the top level, before entering the test execution, auseFakeTimers
is executed on abeforeEach
(see here, on line 67).Temporary solution was to move
useRealTimers
calls inside abeforeEach
, but IMO it would be nice to fix it for keeping compatibility with previous versions :)The text was updated successfully, but these errors were encountered: