-
Hello everyone, I'm currently facing an issue with React Query and MSW in my project and would appreciate any insights or suggestions from the community. Issue Description: I'm using React Query's useQuery hook for data fetching and MSW to mock the API responses in my tests. However, I've encountered a problem where, even though MSW successfully returns a response, the data fetched by useQuery does not trigger a re-render with the new data. Code Example: Testing Log info Expected Behavior: When MSW returns a successful response, useQuery should re-render the component with the new data. Environment Details: React Query Version: 5.8.7 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I have a testing setup here where this works just fine: |
Beta Was this translation helpful? Give feedback.
-
I have checked your repo, and it works well with MSW. However, in my project, react-query does not trigger a re-render. Could this be due to a version difference in MSW? Here is my repository: |
Beta Was this translation helpful? Give feedback.
I found that the reason it does not get data from useQuery is due to using a different testing library. When using react-test-renderer, it is necessary to update the component in order to trigger a re-render and thus receive the data.