Replies: 2 comments 2 replies
-
|
Hi, @jkieboom. That's an interesting observation. To clarify: we're speaking about running MSW in the browser, correct? It looks like we should halt any deferred requests if the user calls We should also add an escape logic in |
Beta Was this translation helpful? Give feedback.
-
Yes, forgot to mention that.
Hmm, but then it would wait for the wrong predicate promise? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Asking as a discussion because I don't have a standalone repro case yet. I'm running into an issue where the
window.fetchpatching will run on top of an already patchedfetch(frommswitself):msw/src/utils/deferNetworkRequestsUntil.ts
Lines 23 to 28 in 115b435
I'm setting up MSW in
beforeEach(teardown inafterEach) and if a test does not make any network request that would wait for MSW to be setup, it is possible for thefetchpatching to happen twice. It looks likestopdoes not "abort" the network request deferral.I'm currently working around the issue by polling for "window.fetch" to be the native fetch again, after calling
stop, but I feel this is a bug inmswfundamentally.Beta Was this translation helpful? Give feedback.
All reactions