question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Coverage unknown with exclusion pattern in "testMatch"

See original GitHub issue

🐛 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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
simontaborcommented, Mar 8, 2019

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
1reaction
rickhanloniicommented, Oct 15, 2018

@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

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - How to test or exclude private unreachable code from ...
I would like to be able to either find a pattern where I can eliminate that "untestable" code, test it or mark that...
Read more >
Test coverage visualization - GitLab Docs
With the help of GitLab CI/CD, you can collect the test coverage information of your favorite testing or coverage-analysis tool, and visualize this ......
Read more >
Configuring Jest
If a file matches the specified glob pattern, coverage information will be collected for it even if no tests exist for this file...
Read more >
Configuring Vitest
Files to exclude from the test run, using glob pattern. ... When defined, Vitest will run all matched files with import.meta.vitest inside.
Read more >
A Guide to Pattern Matching in Vavr - Baeldung
In this section, we have covered the basics of Vavr pattern matching and the following sections will cover various approaches to tackling ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found