-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.solcover.js
26 lines (18 loc) · 1.09 KB
/
.solcover.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const fs = require('fs');
module.exports = {
istanbulReporter: ['html', 'lcov', 'text', 'json', 'json-summary'],
skipFiles: ['mocks/'],
onIstanbulComplete: () => {
const json = require('./coverage/coverage-summary.json');
const { total, ...contracts } = json;
const formatCoverage = (coverage) => `${coverage?.covered}/${coverage?.total} (${coverage?.pct}%)`;
let coverageTable = `|Contract|Statements|Branches|Functions|Lines|\n`;
coverageTable += `|-|-|-|-|-|\n`;
for (const [contract, coverage] of Object.entries(contracts)) {
coverageTable += `|${contract}|${formatCoverage(coverage.statements)}|${formatCoverage(coverage.branches)}|${formatCoverage(coverage.functions)}|${formatCoverage(coverage.lines)}|\n`;
}
coverageTable += `|**Total**|**${formatCoverage(total.statements)}**|**${formatCoverage(total.branches)}**|**${formatCoverage(total.functions)}**|**${formatCoverage(total.lines)}**|\n`;
const markdown = `# Coverage\n\n${coverageTable}`;
fs.writeFileSync('COVERAGE.md', markdown);
}
};