Facing Configuration Errors While Using nock with react-query in a vitest Environment #2519
Unanswered
Michael0520
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
-
Description
I'm trying to integrate nock, react-query, and vitest for testing my React application. Despite following documentation and community advice, I'm encountering unexpected behavior. I hope you can help me debug this issue.
Details
I initially opted to use nock for my examples based on its mention in the official React Query testing documentation. I'm facing issues where the nock setup doesn't seem to work as expected, causing my test cases to fail.
Errors
Timeout failure while waiting for result.current.isSuccess to be true.
result.current.data is undefined.
Additional Context
I received feedback from the maintainer of React Query who suggested that the issue is most likely with the nock setup, not with React Query itself. Here's the error I get:
Sandbox for Reproduction
You can replicate the issue using this CodeSandbox link.
What Have I Tried
Consulted React Query's testing documentation.
Replacing network requests with Promise.resolve() made it work, indicating that React Query is probably not the issue.
Questions
Is there a complete repository example that demonstrates the correct way to use nock with React Query?
Any pointers on what might be causing this issue and how to resolve it?
Beta Was this translation helpful? Give feedback.
All reactions