Testing queryFn with jest & enzyme #2574
Unanswered
dalladirosa
asked this question in
Q&A
Replies: 1 comment 7 replies
-
Not sure, you’re not showing how you call the hook in the test. my approach is not mocking the function, but mocking on the network layer. The docs suggest nock: https://react-query.tanstack.com/guides/testing#testing-network-calls and I personally prefer msw: https://tkdodo.eu/blog/testing-react-query |
Beta Was this translation helpful? Give feedback.
7 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.
-
Hi i want to test queryFn from this line of code
This is what I'm trying to do. I mock getJob function like this
and check if getJob function is called
and i still get an error
Does anyone know what is the right way to test queryFn? Thank you
Beta Was this translation helpful? Give feedback.
All reactions