diff --git a/setupTest.js b/setupTest.js index 0c7c3a98e2..9ee8cad66f 100644 --- a/setupTest.js +++ b/setupTest.js @@ -3,3 +3,12 @@ process.env.CHOKIDAR_USEPOLLING = true; jest.setTimeout(140000); + +if (expect.getState().testPath.includes("test/e2e")) { + afterEach(() => { + // We add listeners to signals when creating a new Server instance, but have no cleanup method + // So ensure they are removed after each run to prevent EventEmitter memory leak warnings + process.removeAllListeners("SIGINT"); + process.removeAllListeners("SIGTERM"); + }); +}