Skip to content

Commit bc1e986

Browse files
FIX: @W-19972333@: Suppress the warning about max listeners when running tests (#1908)
1 parent cd0787c commit bc1e986

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
"summary"
115115
]
116116
],
117+
"setupFiles": ["./test/setup-jest.ts"],
117118
"testEnvironment": "node",
118119
"testMatch": [
119120
"<rootDir>/test/**/*.test.ts"

test/setup-jest.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Note that in a single process our tests create many instances of CodeAnalyzer. For each instance of CodeAnalyzer, a
2+
// call to process.addListener is made to cleanup the root working folder if needed. See
3+
// https://github.com/forcedotcom/code-analyzer-core/blob/dev/packages/code-analyzer-core/src/code-analyzer.ts#L121
4+
// Because of this we would get a lot of warnings. For example:
5+
// (node:2039) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 exit listeners added to [process].
6+
// To suppress these warnings, it is easiest to just allow the process running these tests to allow an infinite amount
7+
// of listeners. So we do that here (where 0 means infinite):
8+
process.setMaxListeners(0);

0 commit comments

Comments
 (0)