Mocking a useMutation and checking number of calls of mutate #2505
Unanswered
leo-petrucci
asked this question in
Q&A
Replies: 2 comments 4 replies
-
the docs don't suggest to mock the actual mutation function, but to rather mock the outgoing network requests. You can do that with something like nock or I would suggest mock-service-worker. |
Beta Was this translation helpful? Give feedback.
4 replies
-
I found this solution:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm having some trouble checking my mutation is actually being launched with Testing Library and Jest.
Consider the following hook:
I'm currently mocking it as:
I then click a button to start my mutation in my test (I've verified this is happening by console.logging), but the following happens:
Any tips on how to handle this? The docs give examples for testing queries, but there's no examples for mutations.
Beta Was this translation helpful? Give feedback.
All reactions