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.

Improve the message when run coverage while there are no tests

See original GitHub issue

🐛 Bug Report

When you run jest with --coverage but there are no tests, it shows error “Jest: Coverage data for global was not found.”

To Reproduce

  1. Delete all test files e.g. *.test.js

  2. Run jest --config=jest.json --coverage with below configuration in jest.json:

{
  "testEnvironment": "node",
  "coverageThreshold": {
    "global": {
      "branches": 90,
      "functions": 90,
      "lines": 90,
      "statements": -10
    }
  },
  "collectCoverageFrom" : [
    "*.js"
  ]
}

Expected behavior

A simple and clear error like “No tests found”, or simply skipping coverage, or coverage report as usual (and failed 100%).

Link to repl or repo (highly encouraged)

https://github.com/Tiendq/lego-part-loader

Run npx envinfo --preset jest

System:
    OS: macOS Sierra 10.12.6
  Binaries:
    Node: 10.0.0 - /usr/local/bin/node
    Yarn: 1.6.0 - /usr/local/bin/yarn
    npm: 5.6.0 - /usr/local/bin/npm
  npmPackages:
    jest: ^22.4.3 => 22.4.3 

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
misoguycommented, May 8, 2018

I’d like to try this if no one is on it 😄

1reaction
rickhanloniicommented, May 26, 2018

Here’s where that error is thrown, should be able to add the check you need somewhere in that function with a nice explination

Read more comments on GitHub >

github_iconTop Results From Across the Web

Improve your component test coverage with this one weird trick
Improve your component test coverage with this one weird trick ... While the pragmatic answer is 'no', sometimes you need to accept that ......
Read more >
Troubleshooting Code Coverage - Visual Studio (Windows)
Explanation—Code coverage analysis is done while tests are running. It only includes assemblies that are loaded into memory when the tests run.
Read more >
How To Test a React App with Jest and React Testing Library
No tests found related to files changed since last commit. Press `a` to run all tests, or run Jest with `--watchAll`. Watch Usage...
Read more >
Why Code Coverage in react app is empty? Tried using npm ...
If you just created a new app and you're getting no code coverage it's most likely because no tests have been written. You...
Read more >
How do I increase my code coverage, or why can't I cover ...
After running unit tests, if the line starting with a.Description is not covered, it's an indication that the loop never begins iterating ......
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