react-websocket/replay
Record WebSocket sessions and play them back without a server. Both functions return WebSocket classes to pass as the WebSocket option. The entry has no React dependency and no imports, and is about 1.7 kB min+gzip. The guide is Recording and replay.
createRecordingWebSocket
A WebSocket class that records what its connections do. options.WebSocket is the one it wraps; the global one by default.
The sockets it creates behave like the wrapped ones. Binary data is received as an ArrayBuffer underneath, so it can be recorded at once, and handed to the app as a Blob or an ArrayBuffer per its binaryType.
createReplayWebSocket
Each socket it creates replays the next recorded connection. One beyond the end of the recording fails with an error and a 1006 close. bufferedAmount is 0, and send() throws while connecting, like a real socket.
WebSocketRecording
t is in ms since the connection was created. Binary data is { binary }, base64. It's plain JSON, so you can write or edit a recording by hand.