Replies: 1 comment 2 replies
-
code looks generally okay.
This would be easier if you would show a running reproduction. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When invalidating a query in the onSuccess handler of a mutation, the test appears to be unable to wait for the new data (and the next render cycle) so that assertions can be made.
When console.log() is placed in onSuccess() as a troubleshooting step, Jest returns an error:
Indicating that asynchronous operations are happening that need to be awaited. Using
waitFor(() => ...)
(even with a custom timeout of 90,000ms) appears to be insufficient.Question:
How do we properly setup query cache invalidation such that a test will wait until the new data has been fetched, and the component rendered so that we can make assertions in the test?
Versions
React
17.x
React Query
3.32
@testing-library/user-event
13.5.0
MyComponent.js
useCustomMutation.js
MyComponent.test.js
Beta Was this translation helpful? Give feedback.
All reactions