Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show unhandled request's initiator #1764

Open
1 task
maksnester opened this issue Oct 10, 2023 · 2 comments
Open
1 task

Show unhandled request's initiator #1764

maksnester opened this issue Oct 10, 2023 · 2 comments
Labels

Comments

@maksnester
Copy link

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.

@kettanaito
Copy link
Member

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?

@gsanta
Copy link

gsanta commented Apr 22, 2024

Is this implemented in the latest version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants