Skip to content

Change Request: Warn when an unintercepted request is detected #106

@TrevorBurnham

Description

@TrevorBurnham

What problem do you want to solve?

One of MSW's most useful debugging features is that (by default) it emits a console warning if it detects a request that doesn't match any defined routes. As far as I can tell, Mentoss doesn't have this feature, even as an option. You can assert that all defined routes matched a request, but you can't assert that all requests matched a defined route.

What do you think is the correct solution?

When there's a request that doesn't match a defined route, MSW emits a warning that looks like this:

  console.warn
    [MSW] Warning: captured a request without a matching request handler:

      • GET http://127.0.0.1:55984/api

    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

That's great, actionable output when figuring out why my tests aren't working. I look at that message and say "OK, I need to either mock the /api route, or prevent that request from being fired during this test."

Participation

  • I am willing to submit a pull request for this change.

Additional comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions