msw
msw copied to clipboard
Show unhandled request's initiator
Scope
Adds a new behavior
Compatibility
- [ ] This is a breaking change
Feature description
This is the log I see in jest tests when there is an unhandled request
console.warn
[MSW] Warning: captured a request without a matching request handler:
• GET http://localhost/some/api/path
If you still wish to intercept this unhandled request, please create a request handler for it.
Read more: https://mswjs.io/docs/getting-started/mocks
at Object.warn (node_modules/msw/src/utils/internal/devUtils.ts:17:11)
at applyStrategy (node_modules/msw/src/utils/request/onUnhandledRequest.ts:208:18)
at onUnhandledRequest (node_modules/msw/src/utils/request/onUnhandledRequest.ts:233:3)
at handleRequest (node_modules/msw/src/utils/handleRequest.ts:80:5)
at node_modules/msw/src/node/SetupServerApi.ts:69:24
What I actually would like to know is the stack trace of the code that initiated the request, similar to what Chrome devtools show in request Initiator tab.
Hey, @maksnester. Thanks for this proposal, I think it makes sense. I wonder if the stack trace from MSW even has access to the request initiator.
Can you try this out?
server.listen({
onUnhandledRequest() {
console.trace('Here')
}
})
Will this trace print the request initiator?
Is this implemented in the latest version?