mswjs / msw

Industry standard API mocking for JavaScript.
https://mswjs.io
MIT License
15.97k stars 519 forks source link

feat: print request body in `onUnhandledRequest` message #2227

Closed bitttttten closed 2 months ago

bitttttten commented 3 months ago

I came to file a feature request very similar https://github.com/mswjs/msw/issues/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 commented 3 months ago

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

bitttttten commented 2 months ago

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 commented 2 months ago

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.