Memory leak when using `--coverage`
See original GitHub issueDo you want to request a feature or report a bug?
This is a bug report.
What is the current behavior?
I was able to isolate an example where adding the --coverage operation will cause a memory leak whereas the absence works just fine.
More specifically, the issue occurs when using a very large JavaScript file (in our case, it’s the asm.js artifact of PSPDFKit for Web. To work with JavaScript files of that size without issues, we have to add the file to the transformIgnorePatterns configuration option. As soon as we do this, the test passes as expected.
This was working fine in v22.2.2 and for the non- --coverage option, this still works fine.
However, when using the --coverage option, this test started to leak memory when we updated from v22.2.2 to v22.3.0. Hence I assume the exact time this started to cause issues is somewhere in this diff.
If the current behavior is a bug, please provide the steps to reproduce and
either a repl.it demo through https://repl.it/languages/jest or a minimal
repository on GitHub that we can yarn install and yarn test.
I set up a repo that reproduces this behavior here.
What is the expected behavior?
yarn jest
and
yarn jest --coverage
Finishes in a reasonable time without causing the heap to explode.
Please provide your exact Jest configuration
https://github.com/PSPDFKit-labs/jest-leak/blob/master/package.json
Run npx envinfo --preset jest in your project directory and paste the
results here
System:
OS: macOS High Sierra 10.13.1
CPU: x64 Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz
Binaries:
Node: 9.7.1
Yarn: 1.3.2
npm: 5.6.0
npmPackages:
jest:
wanted: ^22.4.2
installed: 22.4.2
However, I was also able to reproduce this on other machines (e.g. our CI servers).
I also tried different versions of node without seeing a difference in this behavior.
Please let me know if I can provide further details for you.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:14
- Comments:14 (1 by maintainers)

Top Related StackOverflow Question
I just found out about
coveragePathIgnorePatternsand adding this will make the example pass. I still have no idea why this worked before though.@philipp-spiess We use babel to set up code coverage (
babel-plugin-istanbul), which is why it runs even though you usetransformIgnorePatterns, and the reason you needcoveragePathIgnorePatterns.@mnquintana a reproduction would be nice 🙂