Closed kettanaito closed 4 months ago
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.
Right now, the
connection
event is emitted to the interceptors on the same tick as the WebSocket instance is created. It makes it impossible to observe the changes to that instance while connecting.For example, the client may set a different
.binaryType
on the socket after it's constructed (i.e. starts connecting):For the interceptor to know about that change, we have to emit the connection event on the next tick, when any modifications to the socket are complete (including the event listeners).
This will allow us to properly inherit
.binaryType
on the real socket when callingserver.connect()
. This also gives us a behavior similar to production code, where theopen
event will always be emitted on the next tick. Theconnection
interceptor event must not be emitted before the open event.