Skip to content
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
4 changes: 4 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ export default {
// The test environment that will be used for testing
testEnvironment: 'node',

// Force Jest to exit after all tests complete — prevents hanging on open MongoDB
// handles from integration tests whose afterAll disconnect races with Jest's exit
forceExit: true,
Comment thread
PierreBrisorgueil marked this conversation as resolved.

// Global timeout for tests and hooks (integration tests bootstrap MongoDB + Express)
testTimeout: 15000,

Expand Down
9 changes: 7 additions & 2 deletions lib/services/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ const logger = new winston.createLogger({
new winston.transports.Console({
level: logLevel,
format: consoleFormat,
handleExceptions: true,
// Disable exception handling in test env — each jest.resetModules() re-imports
// this module, and handleExceptions:true registers a new process.uncaughtException
// listener on every import without ever removing the old one, causing listener
// accumulation and heap growth across module reloads in beforeEach hooks.
handleExceptions: process.env.NODE_ENV !== 'test',
Comment thread
PierreBrisorgueil marked this conversation as resolved.
}),
],
exitOnError: false,
Expand Down Expand Up @@ -71,7 +75,8 @@ const getLogOptions = () => {
eol: '\n',
tailable: true,
showLevel: true,
handleExceptions: true,
// Same guard as the Console transport — see comment at top of createLogger call
handleExceptions: process.env.NODE_ENV !== 'test',
humanReadableUnhandledException: true,
};
};
Expand Down
Loading