mswjs / interceptors

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

fix(WebSocket): use literal values for ready state properties #511

Closed kettanaito closed 7 months ago

kettanaito commented 7 months ago

This way, imports to WebSocketOverride do not produce a dependency on the global WebSocket class. Otherwise, the WebSocket.CONNECTING (and similar) throw an error when you import the WebSocket interceptor, even if you are not planning on doing anything with it.

Context: getting the WebSocket undefined error when migrating to the latest Interceptors in MSW:

 FAIL  src/browser/setupWorker/setupWorker.node.test.ts [ src/browser/setupWorker/setupWorker.node.test.ts ]
ReferenceError: WebSocket is not defined
 ❯ node_modules/.pnpm/@mswjs+interceptors@0.26.5/node_modules/@mswjs/interceptors/src/interceptors/WebSocket/WebSocketOverride.ts:22:32
kettanaito commented 7 months ago

Released: v0.26.6 🎉

This has been released in v0.26.6!

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.