Replies: 1 comment 14 replies
-
Hi, @till. Happy to hear from you.
MSW warns on any requests that you haven't mocked to guard you against typos and unintended passthrough requests. You can disable that warning or have a custom logic around it using the onUnhandledRequest option. worker.start({ onUnhandledRequest: 'bypass' }) You can also use this option to ignore bypassed requests to certain domains: worker.start({
onUnhandledRequest(request, print) {
// Never warn about unhandled requests sent to the "*.some.host" destination.
if (request.url.hostname.endsWith('.some.host')) {
return
}
print.warning()
}
})
I don't think this is MSW. We don't modify the bypassed requests in any way so your backend should receive exactly what you're sending from the client. You can triage this quite easily:
|
Beta Was this translation helpful? Give feedback.
-
Hey,
I have a weird situation where I started using MSW to mock out requests in tests (through the server implementation) and then tried to proceed to use the same mocks for my frontend (while developing the app).
There's a weird case where I do requests which are not mocked and MSW picks up (see it in the developer console) on them (letting me know about the request and suggests to add a handler). These requests are not supposed to be mocked and I want them to hit another backend.
Now on to the problem: it seems that the requests I don't want mocked hit my backend service, but they no longer include the cookie header anymore when they hit my backend. This is part of an SDK which uses Axios.
The problem is probably in my own code somewhere as I have been unable to re-produce it with an extracted test case, but I figured, I would ask here if there's anything obvious in the configuration of MSW (or otherwise), that would prevent cookies to work in these scenarios. Or if there's generally a problem with Axios as I saw a couple tickets.
For clarity:
I guess, related to this, is there a way to tell MSW to ignore requests to a certain domain (or URL) so I don't see the messages at all? Or silence them?
After spending a few days on this, I started rebuilding the code in another branch and so far stayed away from the issue, but I am also not yet back to where I was mocking some of my frontend requests.
Beta Was this translation helpful? Give feedback.
All reactions