Unit test coverage reporter for Adana.
npm install adana-format-text --save-dev
Similar to other adana coverage formatters, adana-format-text accepts an adana-compatible coverage results object and produces a report as utf8-encoded string.
Usage with adana-cli
cat coverage.json | adana --format text > report.txt
Usage with karma-adana-reporter
Add adana-format-text to the list of formatters in adana configuration object of the karma configuration file.
formatters: [
{
type: 'text', // indicates usage of the "text" formatter
save: 'reports/text-report.txt', // will write output to file
show: true // will dump the same output to console
}
]
import fs from 'fs';
import adanaFormatText from 'adana-format-text';
fs.readFile('coverage.json', 'utf8', (err, data) => {
const coverage = JSON.parse(data);
const report = adanaFormatText(coverage);
fs.writeFile('text-report.txt', report);
});
Note that if you're using ES5, you will have to access the library via the default
property due to the way exports are handled in Babel 6:
var adanaFormatText = require('adana-format-text').default;