Skip to content
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

Changes legacy timers to modern timers in Jest v27 #34

Open
voicis opened this issue Mar 11, 2022 · 1 comment
Open

Changes legacy timers to modern timers in Jest v27 #34

voicis opened this issue Mar 11, 2022 · 1 comment

Comments

@voicis
Copy link

voicis commented Mar 11, 2022

It's impossible to use wait-for-expect and legacy fake timers with Jest v27.

If you set legacy timers in jest config https://jestjs.io/docs/configuration#timers-string, which enables legacy timers for all tests, however after you call waitForExpect it changes to modern timers and they will be used for the rest of the test.

I suspect that this is because the following code which now sets modern timers by default.

jest.useFakeTimers();

@connorshea
Copy link

connorshea commented May 14, 2022

My solution is somewhat specific but my problem appears to be a combination of this issue and one related to my usage of the msw library. mswjs/msw#1163

I solved it by replacing waitForExpect with waitFor from @testing-library/vue (which needs to be the next version, the stable version doesn't support Vue 3 yet)

selankon added a commit to selankon/lime-app that referenced this issue Nov 9, 2022
It's impossible to use wait-for-expect and legacy fake timers with Jest v27.

So is needed to set legacy timers when using wait for expect and change to fake timers when need to `advanceTimersByTime`.

TheBrainFamily/wait-for-expect#34
TheBrainFamily/wait-for-expect#30
selankon added a commit to selankon/lime-app that referenced this issue Jan 20, 2023
It's impossible to use wait-for-expect and legacy fake timers with Jest v27.

So is needed to set legacy timers when using wait for expect and change to fake timers when need to `advanceTimersByTime`.

TheBrainFamily/wait-for-expect#34
TheBrainFamily/wait-for-expect#30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants