How to test if mutate is called with a correct payload #6640
Answered
by
TkDodo
binhtran04
asked this question in
Q&A
-
Let's say I have an input for the user to enter a name, and then a submit button. After submitting, the application will send a post request to /api/user with the JSON payload Simple component example:
|
Beta Was this translation helpful? Give feedback.
Answered by
TkDodo
Jan 5, 2024
Replies: 1 comment 1 reply
-
my recommendation is to always mock / inspect the network layer and just test if your app behaves correctly. If the network call isn't made with the correct input, your app will hopefully behave differently. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
binhtran04
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
my recommendation is to always mock / inspect the network layer and just test if your app behaves correctly. If the network call isn't made with the correct input, your app will hopefully behave differently.
https://tkdodo.eu/blog/testing-react-query