mswjs / interceptors

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

fix(WebSocket): inherit "binaryType" during original server connections #519

Closed kettanaito closed 4 months ago

kettanaito commented 4 months ago

Originally discovered in browser testing of MSW, where the binaryType wasn't respected. The test was expecting a Uint8Array, calling TextDecoder.decode() on it but getting an error: Error [TypeError]: Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'..

Right now, if the client sets a custom .binaryType on the socket, the original server connection socket will ignore that.

I'm adding the inheritance of the .binaryType property from the mock WebSocket instance to the original WebSocket instance (relevant only in the server.connect() scenario).

kettanaito commented 4 months ago

Released: v0.26.8 🎉

This has been released in v0.26.8!

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.