jestjs / jest

Delightful JavaScript Testing.
https://jestjs.io
MIT License
44.08k stars 6.44k forks source link

[bug?] test case contains logger output will cause memory leak. #5415

Closed erictt closed 5 years ago

erictt commented 6 years ago

I'm not sure it's a bug or not. Maybe it's just because I used it in the wrong way. In my code, the logger.info() function is invoked in some modules, not in the test cases. here is just a simplified version, which caused the same error:

Test Case:

import log4js from 'log4js';

test('Test Log4js ', (done) => {
  log4js.configure({
    appenders: {
      app: {
        type: 'console',
      },
    },
    categories: {
      default: { appenders: ['app'], level: 'info' },
    },
  });

  const logger = log4js.getLogger('defualt');
  logger.info('log test');
  expect(1).toBe(1);
  log4js.shutdown(done);
});

Test Command: jest --forceExit --runInBand --coverage --detectLeaks

Config:

  "jest": {
    "testEnvironment": "node",
    "testPathIgnorePatterns": [
      "/node_modules/",
      "./dist"
    ],
    "coverageReporters": [
      "lcov",
      "text"
    ]
  }

Mac OS X 10.12.6 Jest v22.1.4 log4js 2.5.2 Node v9.4.0

rickhanlonii commented 5 years ago

Hey @erictt, thanks for using jest!

It's hard for me to say for sure without a reproduction repo, but I would guess that log4js isn't cleaning everything up on shutdown, keeping the environment around after every test

If you can post a repo I can confirm but either way this is likely a log4js issue 👍

rickhanlonii commented 5 years ago

Just noticed how old this is, sorry for the delay 😢

github-actions[bot] commented 3 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.