-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Coverage report include test files "__test__" and "*.test.js" #6668
Comments
You can use https://jestjs.io/docs/en/configuration#coveragepathignorepatterns-array-string to remove then. @rickhanlonii @thymikee what do you think about excluding files that are run as tests from coverage automatically? Seems reasonable to me |
I'm in 👍 |
I created fix: PASS ./index.test.js
✓ should anything (4ms)
---------------|----------|----------|----------|----------|-------------------|
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 |
index.test.js | 100 | 100 | 25 | 100 | |
---------------|----------|----------|----------|----------|-------------------|
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 0.669s, estimated 1s
Ran all test suites.
Done in 1.41s. @SimenB |
It works correctly on my machine. $ y jest --coverage
yarn run v1.7.0
$ /Users/simbekkh/repos/jest-invalid-coverage/node_modules/.bin/jest --coverage
PASS ./test.js
✓ should anything (4ms)
----------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files | 71.43 | 50 | 50 | 71.43 | |
index.js | 71.43 | 50 | 50 | 71.43 | 3,8 |
----------|----------|----------|----------|----------|-------------------|
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 0.938s, estimated 1s
Ran all test suites.
✨ Done in 1.56s. I'm on a mac, but that shouldn't matter(?) |
@SimenB |
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: |
@SimenB Yes it helped) |
Oh, so not having a |
When I was working on one |
Good work! |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🐛 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
/home/USER_NAME/.work/project-z
yarn test --coverage
Result:
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
The text was updated successfully, but these errors were encountered: