-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Bug report
Description / Observed Behavior
I have a simple SWR/msw/react/jest setup where in one test, I have instructed MSW to return with one value from an endpoint, and in the other test, to return with a different value. SWR does not respect the new value returned from the endpoint mocked by MSW, and my test fails.
Expected Behavior
I would expect SWR, with caching, to first return the cached result, but then to return the new result given that it's different, meaning that both tests would eventually pass. I have added long timeouts and sleeps to ensure that it isn't just a timing issue on these tests.
Repro Steps / Code Example
swr_caching_react_tests.zip
To run, just download, run yarn
then yarn test
. All versions of libs used are in package.json
Additional Context
I understand that SWR puts forward the idea of wrapping these tests with a config that has an empty provider - however, I don't see why SWR is not eventually seeing the new value coming forth in the MSW handler for the second test.