Front end request not hitting MSW handlers #798
-
Hi all, I have a custom webpack React application where I've set up MSW using Jest within the node approach of setting up MSW. But for some reason when I render my component in my tests, my front end fetch calls do not hit the defined handlers I've used in my One of my theories is that since I include a proxy to my back-end local url in my webpack and does that throw off the url that the handlers are expecting? when I remove it, it still doesn't work.
I tried to set handlers for all possible backend url's like the following
But none of them get console logged. I know the handlers are registered because I went through the debugging section in the docs and printed all handlers. I'm just trying a test component which runs a fetch call on mount Then in my logs I see this (one interesting thing to note is that the Any info on why this might not be working is much appreciated, I've used this library in past applications with success and would love to be able to leverage in this app. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hey, @gerarddegas. Could you please install the latest version of Other than that, it'd be most helpful to have a reproduction repository to look at. |
Beta Was this translation helpful? Give feedback.
-
I just figured it out. I was mocking fetch in my setupTest.ts file and when I removed the fetch mock and imported whatwg-fetch polyfill my request were routed accordingly. Thanks for prompt response and keep up the awesome work! |
Beta Was this translation helpful? Give feedback.
I just figured it out. I was mocking fetch in my setupTest.ts file and when I removed the fetch mock and imported whatwg-fetch polyfill my request were routed accordingly. Thanks for prompt response and keep up the awesome work!