We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When uncovered file contains ignore hints, the statements and lines are not marked as 100. Branches and functions are correctly marked as covered.
100
Save as repro.mjs and run as node repro.mjs. See how branches and functions are covered but statements are not.
repro.mjs
node repro.mjs
import v8ToIstanbul from "v8-to-istanbul"; import { writeFileSync } from "node:fs"; const source = ` /* c8 ignore next 3 */ module.exports = function sum(a, b) { return a + b; }; `.trim(); writeFileSync("test-file.js", source, "utf-8"); const converter = v8ToIstanbul("./test-file.js", 0, { source }); await converter.load(); converter.applyCoverage([ { functionName: "(empty-report)", ranges: [ { startOffset: 0, endOffset: source.length, count: 0, }, ], isBlockCoverage: true, }, ]); const coverageMap = converter.toIstanbul(); const [fileCoverage] = Object.values(coverageMap); const { b, f, s } = fileCoverage; console.log({ b, f, s }); /* $ node coverage-test.mjs { b: { '0': [ 1 ] }, f: { '0': 1 }, s: { '0': 0, '1': 0, '2': 0, '3': 0 } } */
c8
c8-repro ├── index.js ├── package.json └── temp.js
// index.js console.log("Hello world");
// temp.js /* c8 ignore next 3 */ module.exports = function sum(a, b) { return a + b; };
{ "name": "c8-repro", "scripts": { "c8": "c8" }, "dependencies": { "c8": "^8.0.0" } }
$ pnpm run c8 --all node index.js > c8 "--all" "node" "index.js" Hello world ----------|---------|----------|---------|---------|------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s ----------|---------|----------|---------|---------|------------------- All files | 20 | 100 | 100 | 20 | index.js | 100 | 100 | 100 | 100 | temp.js | 0 | 100 | 100 | 0 | 1-4 ----------|---------|----------|---------|---------|-------------------
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
When uncovered file contains ignore hints, the statements and lines are not marked as
100
. Branches and functions are correctly marked as covered.Reproduction
Minimal, without test runner
Save as
repro.mjs
and run asnode repro.mjs
. See how branches and functions are covered but statements are not.With
c8
The text was updated successfully, but these errors were encountered: