Skip to content

Jest 25's change in behaviour of collectCoverageFrom option #9464

@EvHaus

Description

@EvHaus

💥 Regression Report

After upgrading from Jest 24 to Jest 25 we are seeing more files in our coverage reports that we used to have. It seems like the behaviour of the collectCoverageFrom glob patterns has changed.

Last working version

Worked up to version: 24.9.0

Stopped working in version: 25.1.0

To Reproduce

Our folder structure is the following:

  • client/
    • extension/
      • chrome/
        • js/
          • __tests__/
            • some_file.js
          • module.js

Our jest.config.js has the following option:

collectCoverageFrom: [
    '!**/__mocks__/**',
    '!**/__tests__/**',
    'extension/**'
  ],

Expected behavior

The expectation is that coverage is collected from module.js but NOT from some_file.js. In Jest 24 this is the case, but in Jest 25 coverage is being collected from some_file.js even though we've set '!**/__tests__/**',.

To work around this, we had to explicitly add '!extension/chrome/js/__tests__/**' to the list of directories and that made Jest 25 ignore it.

Link to repl or repo (highly encouraged)

Hopefully the details above are enough. If not, I can help setup a test repo to reproduce.

Run npx envinfo --preset jest

Paste the results here:

  System:
    OS: macOS 10.15.2
    CPU: (8) x64 Intel(R) Core(TM) i5-8279U CPU @ 2.40GHz
  Binaries:
    Node: 10.17.0 - ~/.nvm/versions/node/v10.17.0/bin/node
    Yarn: 1.21.1 - /usr/local/bin/yarn
    npm: 6.13.4 - ~/.nvm/versions/node/v10.17.0/bin/npm
  npmPackages:
    jest: 25.1.0 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions