Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
printDurations(zopf.testDurations, msg);
const libCoverage = require("istanbul-lib-coverage");
let map = libCoverage.createCoverageMap(global["__coverage__"]);
const libSourceMaps = require("istanbul-lib-source-maps");
const sourceMapCache = libSourceMaps.createSourceMapStore();
map = sourceMapCache.transformCoverage(map).map;
const libReport = require("istanbul-lib-report");
const context = libReport.createContext({ dir: "coverage" });
const reports = require("istanbul-reports");
const tree = libReport.summarizers.pkg(map);
// print text-lcov report to coverage.lcov file
tree.visit(reports.create("lcov"), context);
let finishedCoverageAt = Date.now();
console.log(
`coverage took ${(finishedCoverageAt - finishedAt).toFixed(2)}ms`
);
if (harness._exitCode === 0) {
console.log(chalk.green("[ OK ]"));
} else {
console.log(chalk.red("[FAIL]"));
}
resolve(harness._exitCode);
});
generateCoverageReport() {
const coveragePath = dappPath(".embark", "coverage.json");
const coverageMap = JSON.parse(this.fs.readFileSync(coveragePath));
const map = coverage.createCoverageMap(coverageMap);
const tree = reporter.summarizers.nested(map);
const ctx = reporter.createContext({ dir: 'coverage' });
const report = reports.create('html', { skipEmpty: false, skipFull: false });
tree.visit(report, ctx);
}
export function createReport(): void {
const iLibCoverage = require('istanbul-lib-coverage');
const iLibSourceMaps = require('istanbul-lib-source-maps');
const iLibReport = require('istanbul-lib-report');
const iReports = require('istanbul-reports');
const global = new Function('return this')();
const mapStore = iLibSourceMaps.createSourceMapStore();
const coverageMap = iLibCoverage.createCoverageMap(global.__coverage__);
const transformed = mapStore.transformCoverage(coverageMap);
const tree = iLibReport.summarizers.flat(transformed.map);
const context = iLibReport.createContext({
dir: path.resolve(REPO_ROOT, `coverage`)
});
const reports = [iReports.create('lcov')];
reports.forEach(report => tree.visit(report, context));
}
message: 'No coverage info! Check your options.src or options.istanbul.exclude to ensure you include proper files'
}));
}
if (!covCfg.reporters || !covCfg.reporters.forEach) {
this.emit('error', new (require('gulp-util').PluginError)({
plugin: pluginName,
message: 'Bad config! Check your options.coverage.reports, it should be an array.'
}));
}
context = report.createContext({
dir: covCfg.directory
});
map = coverage.createCoverageMap(global[coverageVariable]);
tree = report.summarizers.pkg(map);
finalSummary = coverage.createCoverageSummary();
map.files().forEach(function (F) {
finalSummary.merge(map.fileCoverageFor(F).toSummary());
});
covCfg.reporters.forEach(function (R) {
try {
tree.visit(reporters.create(R), context);
} catch (E) {
this.emit('error', new (require('gulp-util').PluginError)({
plugin: pluginName,
message: 'ERROR when generate instanbul report ' + R + ':' + E.message
}));
}
report () {
var tree
var map = this.getCoverageMapFromAllCoverageFiles()
var context = libReport.createContext({
dir: this.reportDirectory(),
watermarks: this.config.watermarks
})
tree = libReport.summarizers.pkg(map)
this.reporter.forEach((_reporter) => {
tree.visit(reports.create(_reporter, {
skipEmpty: this.config.skipEmpty,
skipFull: this.config.skipFull
}), context)
})
if (this._showProcessTree) {
this.showProcessTree()
}
}
generateReport () {
debug('Try to generate report')
const reportsList = this.getPreviousReports()
const map = this.mergeMap(libCoverage.createCoverageMap({}), reportsList)
const context = libReport.createContext({
dir: this.directory
})
const tree = libReport.summarizers.pkg(map)
this.reporters.forEach((reporter) => {
debug(`Generate report for reporter ${reporter}`)
tree.visit(reports.create(reporter), context)
})
}
}
const dir = grunt.config( "dir.tmp_coverage" );
const watermarks = grunt.config( "coverage.watermarks" );
const reporters = grunt.config( "coverage.reporters" );
const libCoverage = require( "istanbul-lib-coverage" );
const libReport = require( "istanbul-lib-report" );
const libSourceMaps = require( "istanbul-lib-source-maps" );
const reports = require( "istanbul-reports" );
const map = libCoverage.createCoverageMap( report );
const sourceMapCache = libSourceMaps.createSourceMapStore();
map.data = sourceMapCache.transformCoverage(
libCoverage.createCoverageMap( map.data )
).map.data;
const tree = libReport.summarizers.pkg( map );
const context = libReport.createContext({ dir, watermarks });
reporters.forEach( ({ name, options }) => {
const report = reports.create( name, options );
tree.visit( report, context );
grunt.log.ok( `Coverage reporter run: ${name}` );
});
}
browsers.forEach((browser: any) => {
const coverage = that.coverageMap.get(browser);
const coverageMap = istanbulCoverage.createCoverageMap();
coverageMap.merge(coverage);
const sourceMapStore = istanbulSourceMaps.createSourceMapStore();
const remappedCoverageMap = sourceMapStore.transformCoverage(coverageMap).map;
const tree = istanbulReport.summarizers.pkg(remappedCoverageMap);
if (results && config.hasCoverageThreshold && !threshold.check(browser, remappedCoverageMap)) {
results.exitCode = 1;
}
Object.keys(config.reports).forEach((reportType: any) => {
const destination = that.getReportDestination(browser, config.reports, reportType);
if (destination) {
that.log.debug("Writing coverage to %s", destination);
}
const context = istanbulReport.createContext( { dir: destination } );
tree.visit(istanbulReports.create(reportType), context);
});
function Reporter(cfg, opts) {
opts = opts || {};
this.config = cfg || configuration.loadFile();
this.dir = path.resolve(this.config.reporting.dir());
this.reports = {};
let summarizer = opts.summarizer;
const s = this.config.reporting.summarizer();
if (summarizer && typeof summarizer === 'function') {
this.summarizer = summarizer;
} else {
summarizer = libReport.summarizers[s];
if (!summarizer) {
throw inputError.create(
'Invalid summarizer in report config: ' + s
);
}
this.summarizer = summarizer;
}
}
function Reporter(cfg, opts) {
opts = opts || {};
this.config = cfg || configuration.loadFile();
this.dir = path.resolve(this.config.reporting.dir());
this.reports = {};
let summarizer = opts.summarizer;
const s = this.config.reporting.summarizer();
if (summarizer && typeof summarizer === 'function') {
this.summarizer = summarizer;
} else {
summarizer = libReport.summarizers[s];
if (!summarizer) {
throw inputError.create(
'Invalid summarizer in report config: ' + s
);
}
this.summarizer = summarizer;
}
}