Course lesson

Intercept a WebSocket connection with Mock Service Worker

To intercept any WebSocket connection in your app, create a WebSocket link using the ws.link() API from MSW. Provide it a URL predicate and store the link in a variable. Then, add the connection event listener to your WebSocket link to know when a connection...

Duration
2 min
Access
Free
Transcript
Needs source

To intercept any WebSocket connection in your app, create a WebSocket link using the ws.link() API from MSW. Provide it a URL predicate and store the link in a variable. Then, add the connection event listener to your WebSocket link to know when a connection is being established. Provide the result of that event listener to your handlers array, and you're good to go!

Resources