-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
React component using useQuery
fails to render data when using jest.useFakeTimers
#4693
Comments
useQuery
alongside useDebounce hook fails to render data when using jest.useFakeTimersuseQuery
alongside useDebounce hook fails to render data when using jest.useFakeTimers
useQuery
alongside useDebounce hook fails to render data when using jest.useFakeTimers
useQuery
fails to render data when using jest.useFakeTimers
It seems that passing |
I mean, you're configuring your runtime to not run per the specification. That will break every tool using So honestly I don't know what we could do to fix that - RTKQ needs them to work :/ |
Sorry if this wasn't clear, but the reason I expect this to work is that the (Here is the relevant code in testing library https://github.com/testing-library/dom-testing-library/blob/a86c54ccda5242ad8dfc1c70d31980bdbf96af7f/src/wait-for.js#L51) I've done some more digging and I'm pretty sure this is the problem:
|
If I move the assignment of |
reading window.requestAnimationFrame within the autoBatchEnhancer function instead of in the top-level module scope. This ensures that we use the fake version of requestAnimationFrame if jest is using fake timers.
reading window.requestAnimationFrame within the autoBatchEnhancer function instead of in the top-level module scope. This ensures that we use the fake version of requestAnimationFrame if jest is using fake timers.
…h fake timers)
reading window.requestAnimationFrame within the autoBatchEnhancer function instead of in the top-level module scope. This ensures that we use the fake version of requestAnimationFrame if jest is using fake timers.
…h fake timers)
reading window.requestAnimationFrame within the autoBatchEnhancer function instead of in the top-level module scope. This ensures that we use the fake version of requestAnimationFrame if jest is using fake timers.
reading window.requestAnimationFrame within the autoBatchEnhancer function instead of in the top-level module scope. This ensures that we use the fake version of requestAnimationFrame if jest is using fake timers.
See here for details on how to reproduce this issue.
You should be able to reproduce the issue just by cloning that repo, running
npm install
and thennpm run test
.There are two tests, each pretty much the same except that one uses fake timers, which seems to cause it to fail.
From what I can tell, the store is always updated with the data from the (stubbed) API response, but when using fake timers this does not result in the react component actually being rendered with the data.
The text was updated successfully, but these errors were encountered: