Skip to content
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

fix: lcov reporter crash when missing branches #613

Merged
merged 2 commits into from Sep 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 10 additions & 5 deletions packages/istanbul-reports/lib/lcovonly/index.js
Expand Up @@ -29,7 +29,8 @@ class LcovOnlyReport extends ReportBase {
const path = require('path');

writer.println('TN:'); //no test nam
writer.println('SF:' + path.relative(this.projectRoot, fc.path));
const fileName = path.relative(this.projectRoot, fc.path);
writer.println('SF:' + fileName);

Object.values(functionMap).forEach(meta => {
writer.println('FN:' + [meta.decl.start.line, meta.name].join(','));
Expand All @@ -50,10 +51,14 @@ class LcovOnlyReport extends ReportBase {

Object.entries(branches).forEach(([key, branchArray]) => {
const meta = branchMap[key];
const { line } = meta.loc.start;
branchArray.forEach((b, i) => {
writer.println('BRDA:' + [line, key, i, b].join(','));
});
if (meta) {
const { line } = meta.loc.start;
branchArray.forEach((b, i) => {
writer.println('BRDA:' + [line, key, i, b].join(','));
});
} else {
console.warn('Missing coverage entries in', fileName, key);
}
});
writer.println('BRF:' + summary.branches.total);
writer.println('BRH:' + summary.branches.covered);
Expand Down