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

feat: print request body in onUnhandledRequest message #2227

Merged
merged 10 commits into from
Aug 28, 2024

Conversation

bitttttten
Copy link
Contributor

@bitttttten bitttttten commented Jul 30, 2024

I came to file a feature request very similar #2161 and thought I'd open a PR.

This will hopefully change this message:

[MSW] Warning: intercepted a request without a matching request handler:

  • POST https://graphql.staging.int.creativefabrica.com/query

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

into

[MSW] Warning: intercepted a request without a matching request handler:

  • POST https://graphql.staging.int.creativefabrica.com/query

  • Request body: { "query": "{ user { id name } }" }

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

@bitttttten
Copy link
Contributor Author

Happy to take suggestions for the formatting of the message. Played with a few formats although settled on this one 🫡

@kettanaito kettanaito changed the title feat: log request details in onUnhandledRequest message feat: log request details in onUnhandledRequest message Aug 28, 2024
kettanaito
kettanaito previously approved these changes Aug 28, 2024
Copy link
Member

@kettanaito kettanaito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for improving MSW, @bitttttten! 👏

I've pushed a few commits to polish this up. It's ready to be released!

@kettanaito kettanaito changed the title feat: log request details in onUnhandledRequest message feat: print request body in onUnhandledRequest message Aug 28, 2024
@kettanaito kettanaito merged commit a2153c9 into mswjs:main Aug 28, 2024
11 checks passed
@bitttttten
Copy link
Contributor Author

I actually was using a local copy of msw where I already added the clone, so thanks so much for fixing and adding that!

@kettanaito
Copy link
Member

Released: v2.4.0 🎉

This has been released in v2.4.0!

Make sure to always update to the latest version (npm i msw@latest) to get the newest features and bug fixes.


Predictable release automation by @ossjs/release.

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

Successfully merging this pull request may close these issues.

Include GraphQL operation name in the unhandled request warning
2 participants