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.

Do not fail on 'Jest: Coverage data for ... was not found.' or make `coverageThreshold` configurable on the cli

See original GitHub issue

🚀 Feature Proposal

We are using one jest.config.js per application and using Bazel as the build/testing tool. The setup there works that each test file will be invoked in isolation/sandboxed via jest. So as soon as I have coverageThreshold: { './some/path/': {...} } some of these test will fail with Jest: Coverage data for ... was not found. Now I could point them all to their individual config, but then I would have to create many many more file which all would be identical apart from the coverageThreshold.

So it would be great to either get a passWithNoCoverage flag or similar, or make coverageThreshold configurable on the cli, so I could just pass that in for each individual jest invocations

Motivation

So I do not have to have duplicate jest.config files

Example

either:

jest --passWithNoCoverage --config=path/to/config.js --runTestsByPath=path/to/test.js

or

jest --coverageThreshold='{\"global\":{\"statements\":90}' --config=path/to/config.js --runTestsByPath=path/to/test.js

Pitch

One of the proposals might even be a bug report, see: https://github.com/facebook/jest/issues/7509 and the addition of the new flag would imo be a good fit to complement the already existing --passWithNoTests flag.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:5
  • Comments:12

github_iconTop GitHub Comments

5reactions
smablycommented, Feb 25, 2022

Our use case is: 1) coverage threshold set, and 2) prepush hook that runs Jest with --changedSince=master to reduce test execution time, since the prepush hook is about getting quick feedback before a full CI run, and 3) not an option for us to run with --no-coverage because meeting our coverage threshold is important if tests are run.

However, I would expect --passWithNoTests to also imply that Jest should pass with no coverage, since there’s no way that a coverage threshold could ever be met if no tests ran.

4reactions
smablycommented, Feb 25, 2022

Absolutely still an issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest finds tests but doesn't collect coverage - Stack Overflow
I found that when upgrading jest (from 23 to 26) that i had this issue, and the resolution was to run with the...
Read more >
Configuring Jest
Thresholds for globs are applied to all files matching the glob. If the file specified by path is not found, an error is...
Read more >
Configuring code coverage in Jest, the right way
In this brief tutorial we see how to configure code coverage for Jest, the right way.
Read more >
Customize pipeline configuration - GitLab Docs
If the CI/CD configuration file is not in the root directory, the path must be relative to it. ... Code coverage data is...
Read more >
jest-coverage-thresholds-bumper - npm package - Snyk
Learn more about jest-coverage-thresholds-bumper: package health score, ... coverage against configured thresholds and fails if there are not enough tests ...
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