Transform WebSocket `connection` on the `ws.link` level
Discussed in https://github.com/mswjs/msw/discussions/2480
Originally posted by colinbes April 22, 2025 I battled coming up with a title to hint at what I am wanting to do.
In my handler I have various rest end point mock handlers as well as io socket listener for mocking of websockets.
I am wanting to mock my backend server behavior which emits status messages of application (running in backend).
For my mocks, as example, when endpoint PUT /app/generator/start I want to start an interval timer and every interval period emit a websocket message sending update of backend process.
I see that ws.link's return value has a broadcast member - would it be correct to use this to emit message to all connected clients?
I am not sure how I would send event plus message though - something like client.emit("send:status", "some valuable update")
Source: mswjs/msw