Replies: 1 comment
-
I think importing the queryCache directly was deprecated with v2.19.0 in favour of creating your own QueryCacheProvider (which then became QueryClientProvider in v3). if you are using testing-library, there is the option of rendering with a wrapper. the advantage is that every test would get their own Provider and thus their own cache, so you don't need to worry about cleanup / concurrent running tests because they are all isolated:
|
Beta Was this translation helpful? Give feedback.
0 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.
-
We use react-query in a number of different places in my company, and have unit tests for specific components.
With the removal of the default cache in version 3, we are facing having to wrap every component in test with a QueryClientProvider. It also seems there is no other way other than using this context to provide it. This is needless to say a major headache for us, and requires refactoring of hundreds of tests.
I wish there was an option to configure react-query in test to keep providing a default cache for cases like this. The removal of the default cache feels like a very drastic move on part of the library developers and I'm wondering if more tips can be provided in the migration guide.
Beta Was this translation helpful? Give feedback.
All reactions