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: support non-configurable responses #677

Merged
merged 10 commits into from
Nov 15, 2024

Conversation

kettanaito
Copy link
Member

@kettanaito kettanaito commented Nov 15, 2024

Warning

A breaking change since isResponseWithoutBody utility is no longer exported from the package's root. Use FetchResponse.isResponseWithBody (notice inversion) instead.

Motivation

Mostly to support passthrough responses like 101 Switching Protocols that happen in the apps that use WebSockets. Technically, also unblocks mocking non-configurable responses, but you have to use custom logic to make that happen (since new Response() will still throw per spec).

  • ClientRequest
  • XMLHttpRequest
  • fetch
  • RemoteHttpInterceptor

Note: In tests, I'm often constructing a 101 response without upgrade, which is technically invalid. The issue is, I don't want to bring the way request clients handle upgrades themselves to tests because that's not the point. Interceptors just has to ensure the non-configurable response status codes are supported from the original server and from the mocks.

@kettanaito kettanaito changed the title fix: support non-configurable responses feat: support non-configurable responses Nov 15, 2024
@kettanaito kettanaito force-pushed the fix/non-configurable-responses branch from 278f22f to f76885d Compare November 15, 2024 11:23
@kettanaito kettanaito force-pushed the fix/non-configurable-responses branch from 37de1ed to 4ba9f64 Compare November 15, 2024 11:34
@kettanaito kettanaito merged commit 1d1cc09 into main Nov 15, 2024
2 checks passed
@kettanaito kettanaito deleted the fix/non-configurable-responses branch November 15, 2024 11:39
@kettanaito
Copy link
Member Author

Released: v0.37.0 🎉

This has been released in v0.37.0!

Make sure to always update to the latest version (npm i @mswjs/interceptors@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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RangeError: init["status"] must be in the range of 200 to 599, inclusive (Undici, Jest)
1 participant