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(onUnhandledRequest): allow default behaviour in a custom callback #1096

Merged

Conversation

JamesZoft
Copy link
Contributor

@JamesZoft JamesZoft commented Feb 11, 2022

Allow users to fall back to the default behaviour for onUnhandledRequest if they just want to cover a small number of scenarios, then hand back control to MSW

@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 11, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 57f6451:

Sandbox Source
MSW React Configuration

…ndledrequest

Allow users to fall back to default behaviour for onunhandledrequest if they just want to cover a
small number of scenarios, then hand back control to msw

addresses mswjs#1080
@kettanaito kettanaito changed the title feat(onunhandledrequest): allow default behaviour fallback for onunhandledrequest feat(onUnhandledRequest): allow default behaviour in a custom fallback Feb 12, 2022
@kettanaito kettanaito changed the title feat(onUnhandledRequest): allow default behaviour in a custom fallback feat(onUnhandledRequest): allow default behaviour in a custom callback Feb 12, 2022
@kettanaito kettanaito force-pushed the onunhandledrequest-allow-default-behaviour branch from f55b5de to 99e3e70 Compare February 12, 2022 11:51
@kettanaito
Copy link
Member

kettanaito commented Feb 12, 2022

Thanks for making this improvement happen, @JamesZoft! 🎉

I've pushed to your feature branch a few minor changes: renamed next to print and made it an object, so the usage looks like this:

onUnhandledRequest(request, print) {
  print.error() // or `print.warning()`
}

Also added a few integration and E2E tests. Everything looks in order!

@kettanaito kettanaito force-pushed the onunhandledrequest-allow-default-behaviour branch from 99e3e70 to 57f6451 Compare February 12, 2022 12:03
@kettanaito kettanaito merged commit 0be131d into mswjs:main Feb 12, 2022
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.

Enable a way to run the default behaviour from inside the onUnhandledRequest callback
2 participants