diff --git a/packages/node-integration-tests/jest.config.js b/packages/node-integration-tests/jest.config.js index 617a25ea0817..81e7d8f63d18 100644 --- a/packages/node-integration-tests/jest.config.js +++ b/packages/node-integration-tests/jest.config.js @@ -1,6 +1,7 @@ const baseConfig = require('../../jest.config.js'); module.exports = { + globalSetup: '/setup-tests.ts', ...baseConfig, testMatch: ['**/test.ts'], }; diff --git a/packages/node-integration-tests/package.json b/packages/node-integration-tests/package.json index 3f09e8d64192..002031983f52 100644 --- a/packages/node-integration-tests/package.json +++ b/packages/node-integration-tests/package.json @@ -11,7 +11,7 @@ "lint:eslint": "eslint . --cache --cache-location '../../eslintcache/' --format stylish", "lint:prettier": "prettier --check \"{suites,utils}/**/*.ts\"", "type-check": "tsc", - "test": "jest --detectOpenHandles --runInBand --forceExit", + "test": "jest --runInBand --forceExit", "test:watch": "yarn test --watch" }, "dependencies": { diff --git a/packages/node-integration-tests/setup-tests.ts b/packages/node-integration-tests/setup-tests.ts new file mode 100644 index 000000000000..6f7bb2bec369 --- /dev/null +++ b/packages/node-integration-tests/setup-tests.ts @@ -0,0 +1,12 @@ +import EventEmitter from 'events'; + +const setup = async (): Promise => { + // Node warns about a potential memory leak + // when more than 10 event listeners are assigned inside a single thread. + // Initializing Sentry for each test triggers these warnings after 10th test inside Jest thread. + // As we know that it's not a memory leak and number of listeners are limited to the number of tests, + // removing the limit on listener count here. + EventEmitter.defaultMaxListeners = 0; +}; + +export default setup;