This repo is to demonstarte a bug of jest empty coverage.
- Use
yarn
to install dependencies
yarn install
- Generate the coverage report.
yarn cover:jest
- Check the file
coverage/coverage-final.json
. The coverage data forBrandTable.jsx
is incorrect. Some value isnull
and-1
.
"statementMap": {
"0": {
"start": { "line": 1, "column": 0 },
"end": { "line": null, "column": -1 }
},
"1": {
"start": { "line": 4, "column": 22 },
"end": { "line": null, "column": -1 }
},
"2": {
"start": { "line": 9, "column": 4 },
"end": { "line": null, "column": -1 }
},
"3": {
"start": { "line": 13, "column": 0 },
"end": { "line": null, "column": -1 }
}
},
-
Add a unit test to
BrandTable.jsx
by renaming thesrc/__tests__/BrandTable-spec
tosrc/__tests__/BrandTable-spec.js
. Now the report data forBrandTable.jsx
is not generate through empty report. -
Generate coverage report
yarn cover:jest
- Check the file
coverage/coverage-final.json
. Now the coverage data forBrandTable.jsx
is correct.
"statementMap": {
"0": {
"start": { "line": 5, "column": 4 },
"end": { "line": 5, "column": 16 }
},
"1": {
"start": { "line": 9, "column": 4 },
"end": { "line": 9, "column": 33 }
},
"2": {
"start": { "line": 13, "column": 0 },
"end": { "line": 13, "column": 37 }
}
},