mswjs / interceptors

Low-level network interception library.
https://npm.im/@mswjs/interceptors
MIT License
565 stars 127 forks source link

feat: support non-configurable responses #677

Closed kettanaito closed 1 week ago

kettanaito commented 1 week ago

[!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).

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 commented 1 week ago

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.