Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Current behavior is for --detectLeaks to report a leak for any --coverage enabled test (which has at least one import)
Reproduction Steps
Steps to repo:
What is the expected behavior?
Expect that --detectLeaks does not fail for minimal --coverage test
Versions
- jest@22.0.6
- yarn@1.3.2
- node@8.9.4
- npm@5.6.0
- macOS@10.13.1
More information
Using the new detectLeaks feature I was able to create a minimal expample repo of a leak when ever coverage is enabled:
// module.js
const noOp = () => {};
module.exports = noOp;
// module.spec.js
const _ = require('./module.js');
test('empty test', () => {
expect(true).toBeTruthy();
});
Screens
Pass:

Fail:

A few notes:
- The module is not used in the test, only imported
- Commenting out the import will pass with coverage
- Moving the module function into the test file will pass
- This is only Jest (i.e. no babel-jest or React)
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Current behavior is for
--detectLeaksto report a leak for any--coverageenabled test (which has at least one import)Reproduction Steps
Steps to repo:
yarnyarn test:pass(this isjest --detectLeaks module.spec.js)yarn test:fail(this isjest --detectLeaks module.spec.js --coverage)What is the expected behavior?
Expect that
--detectLeaksdoes not fail for minimal--coveragetestVersions
More information
Using the new detectLeaks feature I was able to create a minimal expample repo of a leak when ever coverage is enabled:
Screens
Pass:

Fail:

A few notes: