From a34a85e318d91af9dfb8a5ef7eca63e3307d97a9 Mon Sep 17 00:00:00 2001 From: Mike Whiting Date: Sat, 29 Oct 2022 12:29:25 +0100 Subject: [PATCH] add notice regarding setImmediate --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 1d27916..1a39e26 100644 --- a/README.md +++ b/README.md @@ -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