Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
dir: reportOut,
defaultSummarizer: 'nested',
coverageMap,
} );
const reportType = Array.isArray( type ) ? type.pop() : type;
// create an instance of the relevant report class
const report = istanbulReports.create( reportType );
// call execute to synchronously create and write the report to disk
report.execute( context );
// show the report text summary in console only if the reporter is not a text report.
if ( ! reportType.includes( 'text' ) ) {
const text = istanbulReports.create( 'text' );
text.execute( context );
}
};
const generateReport = ( coverageMap, type ) => {
// create a context for report generation
const context = libReport.createContext( {
dir: reportOut,
defaultSummarizer: 'nested',
coverageMap,
} );
const reportType = Array.isArray( type ) ? type.pop() : type;
// create an instance of the relevant report class
const report = istanbulReports.create( reportType );
// call execute to synchronously create and write the report to disk
report.execute( context );
// show the report text summary in console only if the reporter is not a text report.
if ( ! reportType.includes( 'text' ) ) {
const text = istanbulReports.create( 'text' );
text.execute( context );
}
};
add(fmt) {
if (this.reports[fmt]) {
// already added
return;
}
const config = this.config;
const rptConfig = config.reporting.reportConfig()[fmt] || {};
rptConfig.verbose = config.verbose;
try {
if (this.config.verbose) {
console.error('Create report', fmt, ' with', rptConfig);
}
this.reports[fmt] = libReports.create(fmt, rptConfig);
} catch (ex) {
throw inputError.create('Invalid report format [' + fmt + ']');
}
},
/**
add(fmt) {
if (this.reports[fmt]) {
// already added
return;
}
const config = this.config;
const rptConfig = config.reporting.reportConfig()[fmt] || {};
rptConfig.verbose = config.verbose;
try {
if (this.config.verbose) {
console.error('Create report', fmt, ' with', rptConfig);
}
this.reports[fmt] = libReports.create(fmt, rptConfig);
} catch (ex) {
throw inputError.create('Invalid report format [' + fmt + ']');
}
},
/**
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);
}
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));
}
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);
});
});
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
}));
}
});
if (isCoverageMap(data)) {
map = data;
} else {
map = createCoverageMap(data);
}
const transformed = this.executor.sourceMapStore.transformCoverage(map);
const context = createContext({
dir: this.directory,
sourceFinder: transformed.sourceFinder,
watermarks: this.watermarks
});
const tree = summarizers.pkg(transformed.map);
const report = create(type, this.getReporterOptions());
tree.visit(report, context);
}
reporters.forEach( ({ name, options }) => {
const report = reports.create( name, options );
tree.visit( report, context );
grunt.log.ok( `Coverage reporter run: ${name}` );
});
}