Skip to content

Commit

Permalink
add notice regarding setImmediate
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejw authored and romgain committed Oct 29, 2022
1 parent af7ade6 commit a34a85e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,17 @@ afterEach(() => {

`mock-socket` has a strong usage of delays (`setTimeout` to be more specific). This means using `jest.useFakeTimers();` will cause issues such as the client appearing to never connect to the server.

While running the websocket server from tests within the jest-dom environment (as opposed to node)
you may see errors of the nature:

```bash
ReferenceError: setImmediate is not defined
```

You can work around this by installing the setImmediate shim from
[https://github.com/YuzuJS/setImmediate](https://github.com/YuzuJS/setImmediate) and
adding `require('setimmediate');` to your `setupTests.js`.

## Testing React applications

When testing React applications, `jest-websocket-mock` will look for
Expand Down

0 comments on commit a34a85e

Please sign in to comment.