Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
emitter: emitter
})
var remappedCoverageMap = sourceMapStore.transformCoverage(coverageMap).map
// If config.check is defined, check coverage levels for each browser
if (config.hasOwnProperty('check') && !checkedCoverage[browser.id]) {
checkedCoverage[browser.id] = true
var coverageFailed = checkCoverage(browser, remappedCoverageMap)
if (coverageFailed) {
if (results) {
results.exitCode = 1
}
}
}
var context = istanbulLibReport.createContext(options)
var tree = istanbulLibReport.summarizers.pkg(remappedCoverageMap)
var report = reports.create(reporterConfig.type || 'html', options)
// // If reporting to console or in-memory skip directory creation
var toDisk = !reporterConfig.type || !reporterConfig.type.match(/^(text|text-summary|in-memory)$/)
if (!toDisk && reporterConfig.file === undefined) {
tree.visit(report, context)
return
}
helper.mkdirIfNotExists(outputDir, function () {
log.debug('Writing coverage to %s', outputDir)
tree.visit(report, context)
})
})
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));
}
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);
}
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)
})
}
}
module.exports = async function report (coverageMap, {
reportDir: dir = 'coverage',
reporters = ['lcov', 'text']
} = {}) {
const context = createContext({ dir });
const tree = summarizers.pkg(coverageMap);
arrify(reporters).forEach(reporter =>
tree.visit(
reports.create(reporter),
context
)
);
};
write(coverageMap, opts) {
opts = opts || {};
const sourceFinder = opts.sourceFinder || null;
const context = libReport.createContext({
dir: this.dir,
watermarks: this.config.reporting.watermarks(),
sourceFinder
});
const excludes = this.config.instrumentation.excludes() || [];
coverageMap.filter(
file =>
!excludes.some(exclude =>
minimatch(file, exclude, { dot: true })
)
);
const tree = this.summarizer(coverageMap);
Object.keys(this.reports).forEach(name => {
async reportCoverage(coverageReport, environment) {
this.coverageMap.merge(coverageReport);
const coverageMap = createCoverageMap(coverageReport);
const remappedCoverageMap = await createSourceMapStore().transformCoverage(coverageMap);
const reportDir = this.coverageDir.directory(environment);
const context = createContext({
dir: reportDir.path,
watermarks: getDefaultWatermarks(),
coverageMap: remappedCoverageMap,
});
createReporter('html').execute(context);
createReporter('lcovonly').execute(context);
}
}
async report () {
const libReport = require('istanbul-lib-report')
const reports = require('istanbul-reports')
const context = libReport.createContext({
dir: this.reportDirectory(),
watermarks: this.config.watermarks,
coverageMap: await this.getCoverageMapFromAllCoverageFiles()
})
this.reporter.forEach((_reporter) => {
reports.create(_reporter, {
skipEmpty: this.config.skipEmpty,
skipFull: this.config.skipFull,
projectRoot: this.cwd,
maxCols: process.stdout.columns || 100
}).execute(context)
})
if (this._showProcessTree) {
await this.showProcessTree()
const map = istanbulCoverage.createCoverageMap();
const mapFileCoverage = fileCoverage => {
fileCoverage.path = fileCoverage.path.replace(
/(.*packages\/.*\/)(build)(\/.*)/,
'$1src$3'
);
return fileCoverage;
};
Object.keys(coverage).forEach(filename =>
map.addFileCoverage(mapFileCoverage(coverage[filename]))
);
const context = istanbulReport.createContext({coverageMap: map});
['json', 'lcov', 'text'].forEach(reporter =>
istanbulReports.create(reporter, {}).execute(context)
);