-
Notifications
You must be signed in to change notification settings - Fork 467
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
waitFor should work with fake timers #661
Comments
I think this is absolutely better than the test failing incorrectly. So I vote yes detect and use this. Improvements can be made incrementally. |
I've got another idea that I think will work better. Working on it now: https://kcd.im/discord |
Got it! I'm pretty happy with it: #662 |
Really cool idea. I spent quite some time yesterday to help a colleague debug a test exactly because of this! |
🎉 This issue has been resolved in version 7.17.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
+1 I also noticed that jest uses sinon fake timers. Is that true? |
Relevant code or config:
What you did:
I expected
waitFor
to work even with jest fake timers enabledWhat happened:
It times out because there's nothing telling jest to advance timers
Reproduction:
https://github.com/kentcdodds/testing-library-fake-timers
Problem description:
When enabling fake timers with DOM Testing Library, the
waitFor
utility doesn't work (so none of the other async utils will either). The reason for this is there's nothing telling the clock to advance the timers.Suggested solution:
I'm pretty sure we actually do want the async utils to work seamlessly when fake timers are enabled.
Here's a
waitFor
function that will work only if fake timers are enabled. Maybe we can detect fake timers (we already have a function for this) and if they're enabled, then we could do this instead?It's pretty basic, it doesn't support timeout etc. But it's a good start.
Mostly, I'm looking for feedback. Should we do something like this if fake timers are enabled? Or is there another approach we can take?
The text was updated successfully, but these errors were encountered: