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

Not working for modern fake timers (jest v27) #30

Open
dan-lee opened this issue Jul 16, 2021 · 2 comments
Open

Not working for modern fake timers (jest v27) #30

dan-lee opened this issue Jul 16, 2021 · 2 comments

Comments

@dan-lee
Copy link

dan-lee commented Jul 16, 2021

wait-for-expect does not work in combination with modern fake timers which are default in jest v27. Probably related issue: callstack/react-native-testing-library#775

@noahtallen
Copy link

I had the same issue. Essentially, wait for expect would always time out no matter what, as if its timeouts were not being advanced.

However, I can fix the issue by doing the following:

beforeAll( () => {
  jest.useFakeTimers(); 
  // OR
  jest.useRealTimers();
} )

for some reason, it fails if I do nothing, but succeeds if I tell jest to use either timer variant. Not sure what's up with that.

@connorshea
Copy link

It seems like dd272db is probably relevant to what causes this issue? FWIW the beforeAll trick doesn't seem to work for me.

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
wilsonpage added a commit to wilsonpage/wait-for-expect that referenced this issue Jul 26, 2023
The existing check for jest fake timers no longer works as jest v27 mutates the `setTimeout` global differently. This patch checks for both the old and new formats.
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

3 participants