Skip to content

ref(tests): Suppress unconstructive listener and open handle warnings. #4951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions packages/node-integration-tests/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const baseConfig = require('../../jest.config.js');

module.exports = {
globalSetup: '<rootDir>/setup-tests.ts',
...baseConfig,
testMatch: ['**/test.ts'],
};
2 changes: 1 addition & 1 deletion packages/node-integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
12 changes: 12 additions & 0 deletions packages/node-integration-tests/setup-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import EventEmitter from 'events';

const setup = async (): Promise<void> => {
// 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;