Jest: Coverage unknown with exclusion pattern in "testMatch"

Created on 15 Oct 2018  路  6Comments  路  Source: facebook/jest

馃悰 Bug Report

Coverage becomes unknown after adding an exclusion patter to the testMatch config option.

|-----------|----------|----------|----------|----------|-------------------|
| File      |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
|-----------|----------|----------|----------|----------|-------------------|
| All files |  Unknown |  Unknown |  Unknown |  Unknown |                   |
|-----------|----------|----------|----------|----------|-------------------|

To Reproduce

  • Clone example repo + npm install
  • Run jest --coverage (should show unknown coverage)
  • Remove line 11 in package.json
  • Run jest --coverage (should show correct coverage)

Expected behavior

Coverage report should be the same with or without the exclusion pattern.

Link to repl or repo (highly encouraged)

https://github.com/g-harel/jest-7165

Run npx envinfo --preset jest

  System:
    OS: Linux 4.15 Ubuntu 18.04.1 LTS (Bionic Beaver)
    CPU: x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
  Binaries:
    Node: 9.5.0 - ~/.nvm/versions/node/v9.5.0/bin/node
    npm: 6.4.1 - ~/.nvm/versions/node/v9.5.0/bin/npm
  npmPackages:
    jest: ^23.6.0 => 23.6.0
Bug Confirmed good first issue

Most helpful comment

I'm still getting the exact same issue on Jest v24.3.1. Removing the exclusion pattern fixes it.

Jest config:


module.exports = {
  setupFiles: ['<rootDir>/jest-env.js'],
  testMatch: ['**/*.test.js', '!**/*.integ.test.js'],
  testEnvironment: 'node',
  verbose: true,
  collectCoverage: true,
  coverageReporters: ['text', 'html', 'lcov'],
  coverageDirectory: 'coverage/unit',
};

Env info:

  System:
    OS: macOS 10.14
    CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
  Binaries:
    Node: 8.10.0 - ~/.nvm/versions/node/v8.10.0/bin/node
    Yarn: 1.12.3 - /usr/local/bin/yarn
    npm: 5.6.0 - ~/.nvm/versions/node/v8.10.0/bin/npm
  npmPackages:
    jest: ^24.3.1 => 24.3.1

All 6 comments

Confirmed:

I'd like to give this one a shot, do you have any pointers?

I have a feeling it is related to the patterns being "inverted" individually instead of as a unit when removing test files from coverage recording.

@g-harel that would be great, after getting the repo running locally, I would start in the reporter here and work backward. You may end up here at some point

Thanks, that's exactly where I needed to check!

I'm still getting the exact same issue on Jest v24.3.1. Removing the exclusion pattern fixes it.

Jest config:


module.exports = {
  setupFiles: ['<rootDir>/jest-env.js'],
  testMatch: ['**/*.test.js', '!**/*.integ.test.js'],
  testEnvironment: 'node',
  verbose: true,
  collectCoverage: true,
  coverageReporters: ['text', 'html', 'lcov'],
  coverageDirectory: 'coverage/unit',
};

Env info:

  System:
    OS: macOS 10.14
    CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
  Binaries:
    Node: 8.10.0 - ~/.nvm/versions/node/v8.10.0/bin/node
    Yarn: 1.12.3 - /usr/local/bin/yarn
    npm: 5.6.0 - ~/.nvm/versions/node/v8.10.0/bin/npm
  npmPackages:
    jest: ^24.3.1 => 24.3.1

It seems to be working correctly in g-harel/jest-7165 with v24.3.1 and the test from #7170 is also still passing. It could be a similar reason, but it doesn't look like the exact same cause.

Was this page helpful?
0 / 5 - 0 ratings