Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,6 @@ fastify.register(require('@fastify/websocket'), {
})
```

### Testing

Testing the ws handler can be quite tricky, luckily `fastify-websocket` decorates fastify instance with `injectWS`,
which allows easy testing of a websocket endpoint.

The signature of injectWS is the following: `([path], [upgradeContext])`.


### Creating a stream from the WebSocket

```js
Expand All @@ -296,6 +288,13 @@ fastify.get('/', { websocket: true }, (socket, req) => {
await fastify.listen({ port: 3000 })
```

### Testing

Testing the ws handler can be quite tricky, luckily `fastify-websocket` decorates fastify instance with `injectWS`,
which allows easy testing of a websocket endpoint.

The signature of injectWS is the following: `([path], [upgradeContext])`.

#### App.js

```js
Expand Down