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 report include test files "__test__" and "*.test.js"

See original GitHub issue

🐛 Bug Report

When I run the tests on the local machine my tests coverage 85%, but when the tests pass to my CI testing coverage there is 83% And the reason for this difference is that on the local machine in the calculation of coverage tests take part in test (*.test.js, __test__/*) files.

To Reproduce

  1. save your project with jest to hidden folder /home/USER_NAME/.work/project-z
  2. run command in yarn test --coverage Result:
 PASS  ./test.js
  ✓ should anything (3ms)

----------|----------|----------|----------|----------|-------------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files |    81.82 |       50 |    33.33 |    81.82 |                   |
 index.js |    71.43 |       50 |       50 |    71.43 |               3,8 |
 test.js  |      100 |      100 |       25 |      100 |                   |
----------|----------|----------|----------|----------|-------------------|
Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        0.674s, estimated 1s
Ran all test suites.
Done in 1.42s.

Expected behavior

Test coverage should not contain test files

Link to repl or repo (highly encouraged)

https://github.com/retyui/jest-invalid-coverage

npx envinfo --preset jest Results:

  System:
    OS: Linux 4.15 Linux Mint 18.3 (Sylvia)
    CPU: x64 Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
  Binaries:
    Node: 8.11.3 - /usr/bin/node
    Yarn: 1.7.0 - /usr/bin/yarn
    npm: 5.6.0 - /usr/bin/npm
  npmPackages:
    jest: ^23.1.0 => 23.1.0 

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11

github_iconTop GitHub Comments

1reaction
thymikeecommented, Jul 10, 2018

When I was working on one micromatch PR I noticed that not all calls have {dots: true} option set. It’s probably this.

1reaction
SimenBcommented, Jul 10, 2018

I’m unable to reproduce, then…

I doubt it matters, but does it still happen if you put your project outside of a dotdir? I noticed this in your config: .all-work/

Read more comments on GitHub >

github_iconTop Results From Across the Web

Running tests and creating code coverage reports for React ...
This guide will walk you through continuously running tests and creating code coverage reports in Jenkins. It is written with React in mind...
Read more >
Improving Test Reports: Adding Test Coverage Information
Our tests now include a chart that shows our total test coverage. It specifies the file triangle.js as well as the percentage of...
Read more >
How to run Jest tests with coverage for one file - Stack Overflow
The solution is to add one small option --collectCoverageFrom to collect only for a certain file (i.e. component). This is based on this ......
Read more >
Ensure all source files are included in test coverage reports ...
In this lesson we'll learn how to ensure all source files are included in coverage reports and how to enforce a specific threshold...
Read more >
Full code-coverage with Jest - tsmx
Testing uncovered lines ... After running our first test, the output of npm run test-coverage shows uncovered lines 9-12. They are marked red, ......
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