Skip to content

Memory leak reported by detectLeaks for minimal coverage example #5285

@rickhanlonii

Description

@rickhanlonii

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions