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

onUnhandledRequest: Throws an exception when using the "error" strategy #856

Merged
merged 2 commits into from
Aug 9, 2021

Conversation

kettanaito
Copy link
Member

@kettanaito kettanaito commented Aug 9, 2021

GitHub

Changes

  • When the "error" strategy of the onUnhandledRequest option is used, any request that has no matching request handler will throw an exception to halt request processing and fail any code dependant on it:
await fetch('https://api.com/unhandled')
// FethError: ...
  • The developer-friendly console.error is preserved because the message is too verbose to be used as the FetchError reason. Instead, the fetch error reason is a compact summary of why the request failed (cannot be performed as-is).

@kettanaito kettanaito added BREAKING CHANGE Pull request introducing breaking changes. DX labels Aug 9, 2021
@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 9, 2021

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 b403936:

Sandbox Source
MSW React Configuration

@kettanaito kettanaito merged commit 99646b9 into master Aug 9, 2021
@kettanaito kettanaito deleted the 855-unhandled-error-exception branch August 9, 2021 10:32
@vai0
Copy link

vai0 commented Oct 7, 2021

Thank you for this amazing library. Does throwing an error also stop tests that depend on setupWorker()?

@vai0
Copy link

vai0 commented Oct 7, 2021

Thank you for this amazing library. Does throwing an error also stop tests that depend on setupWorker()?

Answered my own question - it does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BREAKING CHANGE Pull request introducing breaking changes. DX
Projects
None yet
Development

Successfully merging this pull request may close these issues.

onUnhandledRequest: throw error should fail test
2 participants