You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How do I trigger a revalidation when using React Testing Library? I'd like to test my SWR error handling and how my code handles transitioning from valid to error state. Sample code, using Jest, Testing Library, and MSW:
I'm passing key to mount a new component. The console log messages show that the first component mounts and renders and the MSW handler is invoked (as expected), and then the second component mounts and renders with the stale data (as expected), but the MSW handler is never re-invoked.
I'm assuming that there's something to do with the various promises and effects used by SWR, but I'm not sure how to properly process and flush them.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
How do I trigger a revalidation when using React Testing Library? I'd like to test my SWR error handling and how my code handles transitioning from valid to error state. Sample code, using Jest, Testing Library, and MSW:
I'm passing
key
to mount a new component. The console log messages show that the first component mounts and renders and the MSW handler is invoked (as expected), and then the second component mounts and renders with the stale data (as expected), but the MSW handler is never re-invoked.I'm assuming that there's something to do with the various promises and effects used by SWR, but I'm not sure how to properly process and flush them.
Any ideas?
Beta Was this translation helpful? Give feedback.
All reactions