- Introduction
- Quick start
- Philosophy
- Comparison
- Default behaviors
- Limitations
- Debugging runbook
- FAQ
- Mocking HTTP
- Mocking GraphQL
- Mocking WebSocket
- Integrations
- API
- CLI
- Best practices
- Recipes
Sending data
Sending mock data to the original WebSocket server.
Once you establish the actual server connection by calling server.connect()
, your event handler can start sending mock data to the original server via the server.send()
method.
api.addEventListener('connection', ({ server }) => {
server.connect()
server.send('hello world')
})
server.send()
has the same call signature as supported data types asclient.send()
.
This is handy for triggering a particular server behavior by emulating a client-sent event (including those the client hasn’t sent).
API reference
server.send()
The `server.send()` API reference.