No QueryClient set in unit test with react-testing-library #5824
Unanswered
fredericbahr
asked this question in
Q&A
Replies: 0 comments
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.
-
After an upgrade to a newer version of react query i always receive the error
No QueryClient set, use QueryClientProvider to set one
.I currently use the following versions:
@tanstack/react-query
: ^4.29.19@testing-library/react
: ^14.0.0,My unit test looks like this:
ui-test-utils/renderer.ts
tests/test-file.ts
If i change the test file to include an QueryClientProver inside the render function it works:
MyComponentToTest
uses an custom hook which usesuseQueryClient
to access the client.I want to abstract the QueryClientProvider as setting it on every testcase would require me to update over 500 tests.
Is there any changes to react-query that disables this kind of abstraction?
HINT:
i tried to add
contextSharing={true}
to theQueryClientProvider
, but it did not fix my issue.Thanks in advance
Freddy
Beta Was this translation helpful? Give feedback.
All reactions