https://github.com/darekkay/jest-coverage
https://github.com/darekkay/jest-coverage
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/darekkay/jest-coverage
- Owner: darekkay
- Created: 2018-04-16T08:31:14.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-07-28T16:00:53.000Z (almost 4 years ago)
- Last Synced: 2025-02-13T13:50:05.094Z (4 months ago)
- Language: JavaScript
- Size: 118 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Example project to reproduce [Issue 5427](https://github.com/facebook/jest/issues/5427) in Jest.
```
npm install
npm run test
```**Goal**: Enforce an 80% overall coverage **and** a 50% single file coverage.
This example includes:
- four fully tested files (`sum-0x`)
- one partially tested file `product.js`In `[email protected]`, we get the following:
```
$ npm run test> @ test C:\jest-coverage
> jest --coveragePASS app/sum-03.test.js
PASS app/product.test.js
PASS app/sum-04.test.js
PASS app/sum-02.test.js
PASS app/sum-01.test.js
------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
------------|---------|----------|---------|---------|-------------------
All files | 91.67 | 50 | 100 | 91.67 |
product.js | 75 | 50 | 100 | 75 | 6
sum-01.js | 100 | 100 | 100 | 100 |
sum-02.js | 100 | 100 | 100 | 100 |
sum-03.js | 100 | 100 | 100 | 100 |
sum-04.js | 100 | 100 | 100 | 100 |
------------|---------|----------|---------|---------|-------------------Test Suites: 5 passed, 5 total
Tests: 5 passed, 5 total
Snapshots: 0 total
Time: 1.109 s
```Jest reports a successful result, even though the overall branch coverage does not fulfill the `global` threshold (80%).
As discussed, the reason is that Jest uses `global` for all files that are unmatched by other threshold patterns (in this example, there are no other files). In other words, `global` rather means `everythingElse` or `unmatched`.---
NOTE: When I first created this repository, I have referenced a previous version `[email protected]` where I considered this issue not to be present. But I don't think this is true. This idea revolved around a `Coverage data for global was not found` warning that I cannot reproduce anymore in the latest version.