One in-memory loopback connection. Every send is echoed back and can be drained with receive.
send
receive
const opened = createMockLoopbackNetwork(['wss://events.example.org']).open('wss://events.example.org/feed');if (opened.ok) { opened.socket.send('ping'); opened.socket.receive() === 'ping'; } Copy
const opened = createMockLoopbackNetwork(['wss://events.example.org']).open('wss://events.example.org/feed');if (opened.ok) { opened.socket.send('ping'); opened.socket.receive() === 'ping'; }
Readonly
Whether the socket is still open.
Everything sent so far.
Target URL as opened.
Close the socket; idempotent.
Dequeue the next echoed frame, or undefined when empty.
undefined
Send a frame; it is echoed into the receive queue. Returns false once closed.
false
One in-memory loopback connection. Every
sendis echoed back and can be drained withreceive.Example