Lesson

Establish Actual WebSocket Server Connection with MSW

Establish the actual WebSocket server connection in your mock using Mock Service Worker.

Access
Included
Transcript
Needs source

Let's add some realism to our mocks. We can get the server object from the connection listener arguments and establish a connection to the actual WebSocket server by calling server.connect(). Once we do that, our event handler becomes a proxy sitting in-between our client and the actual server.

Resources