Whitelist a request #1231
-
I have a couple of requests I need to be ignored by MSW - is there a way to achieve this? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 14 replies
-
Hey, @rosshulford. Passthrough by defaultMSW only captures those requests which you describe in your request handlers. All other requests won't be affected and will be performed as-is. In the browser, all requests will go through the Service Worker regardless if they should be mocked or not. This is an implementation detail of the library and should not affect you in any way (the original responses will be returned in case a request doesn't have a corresponding request handler on your side). Whitelist for
|
Beta Was this translation helpful? Give feedback.
-
Many thanks.
…On Tue, May 24, 2022 at 12:54 PM Artem Zakharchenko < ***@***.***> wrote:
I'm marking this as the answer because it goes at length about
whitelisting with MSW. You can ask follow-up questions if this answer isn't
enough.
—
Reply to this email directly, view it on GitHub
<#1231 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AH7Z7UEPGOHTRLLCYJVL7NDVLS7PTANCNFSM5VU2LHWQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
@kettanaito may I hide unhandled requests from browser's devtools as well? It is quite annoying too have a lot of unnecessary requests such as chunks and assets in network tab. |
Beta Was this translation helpful? Give feedback.
Hey, @rosshulford.
Passthrough by default
MSW only captures those requests which you describe in your request handlers. All other requests won't be affected and will be performed as-is.
In the browser, all requests will go through the Service Worker regardless if they should be mocked or not. This is an implementation detail of the library and should not affect you in any way (the original responses will be returned in case a request doesn't have a corresponding request handler on your side).
Whitelist for
onUnhandledRequest
By default, MSW will try to warn you when a passthrough request happens. This is an optimal DX in regards to people forgetting to mock requests or making typos in the…