how to test onSuccess callback provided by useSWR #2752
Unanswered
yashpandit
asked this question in
Q&A
Replies: 0 comments
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.
Uh oh!
There was an error while loading. Please reload this page.
-
I have been using the
onSuccess
callback frequently to manage things that should happen once I get a response from the server and sometimes it has complicated logic that should be unit tested.However, I have not been able to come up with a good strategy to unit test the
onSuccess
callback. I have a wrapper hook around useSWR that handles some biz logic and a mock that serves very well for testing/mocking server responses. Has anyone else faced this issue or has a strategy they can share here?I am using Jest with RTL. Appreciate any help. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions