Testing useInfiniteQuery
Hey, I was following official docs suggestions on how to test infinite queries. https://tanstack.com/query/v4/docs/guides/testing#testing-load-more--infinite-scroll
However, suggestion to for
isFetching and then !isFetching seems to result in a flaky tests.
What worked for me, is to await the result itself
Has anyone encountered the same issue?Testing | TanStack Query Docs
React Query works by means of hooks - either the ones we offer or custom ones that wrap around them.
With React 17 or earlier, writing unit tests for these custom hooks can be done by means of the React Hooks Testing Library library.

3 Replies
vicious-goldOP•4y ago
I've made an example based on Dominik's examples in GitHub. Around a third of the flaky tests fail.
https://github.com/arnassavickas/testing-react-query/blob/main/src/tests/hooks.test.tsx
GitHub
testing-react-query/hooks.test.tsx at main · arnassavickas/testing-...
Contribute to arnassavickas/testing-react-query development by creating an account on GitHub.
rare-sapphire•4y ago
I also like this approach more. would you like to update the section in the docs?
vicious-goldOP•4y ago
Alright, will do!