HTML formatter for esnext-coverage.
Similar to other coverage formatters, esnext-coverage-format-html accepts a coverage results object and produces a report as an utf8-encoded string.
npm install esnext-coverage-format-html --save-dev
Add esnext-coverage-format-html to the list of reporters in esnext-coverage configuration object or to your karma configuration file.
reporters: [
{
formatter: 'html', // require esnext-coverage-format-html
outFile: 'reports/coverage.html' // write output to file
}
]
esnext-coverage format coverage.json -f html -o report.html
import fs from 'fs';
import formatter from 'esnext-coverage-format-html';
fs.readFile('coverage.json', 'utf8', (err, data) => {
const coverage = JSON.parse(data);
const report = formatter(coverage);
fs.writeFile('coverage.html', report);
});