Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
path: 'foo',
statementMap: {},
fnMap: {},
branchMap: {},
s: {},
f: {},
b: {}
};
const summary1 = createCoverageSummary(summaryData);
summary1.data;
summary1.branches;
summary1.lines;
summary1.functions;
summary1.statements;
const summary2 = createCoverageSummary(summary1);
const map1 = createCoverageMap(coverageMapData);
map1.data;
const map2 = createCoverageMap(map1);
map2.data;
const fileCoverage1 = createFileCoverage('path/to/foo');
fileCoverage1.data;
const fileCoverage2 = createFileCoverage(fileCoverage1.data);
fileCoverage2.data;
const fileCoverage3 = createFileCoverage(fileCoverageData);
fileCoverage3.data;
// CoverageSummary methods and properties
summary1.isEmpty();
summary1.toJSON();
exports.coverageJsonToReport = function (json, base) {
const map = libCoverage.createCoverageMap(json)
const globalSummary = libCoverage.createCoverageSummary()
const report = { '*': {} }
const summaries = {}
let commonRoot
// inspect and summarize all file coverage objects in the map
for (const file of map.files()) {
const folder = relative(base, dirname(file)) + '/'
const path = new Path(folder)
commonRoot = commonRoot ? commonRoot.commonPrefixPath(path) : path
if (!summaries[folder]) {
summaries[folder] = libCoverage.createCoverageSummary()
report[folder] = { files: {} }
}
const map = libCoverage.createCoverageMap(json)
const globalSummary = libCoverage.createCoverageSummary()
const report = { '*': {} }
const summaries = {}
let commonRoot
// inspect and summarize all file coverage objects in the map
for (const file of map.files()) {
const folder = relative(base, dirname(file)) + '/'
const path = new Path(folder)
commonRoot = commonRoot ? commonRoot.commonPrefixPath(path) : path
if (!summaries[folder]) {
summaries[folder] = libCoverage.createCoverageSummary()
report[folder] = { files: {} }
}
const fileSummary = map.fileCoverageFor(file).toSummary()
globalSummary.merge(fileSummary)
summaries[folder].merge(fileSummary)
report[folder].files[basename(file)] = getSimpleCoverage(fileSummary)
}
report['*'] = getSimpleCoverage(globalSummary)
const folders = Object.keys(summaries)
while (folders.length > 1 && summaries[commonRoot.toString() + '/']) {
commonRoot = commonRoot.parent()
}
branches: { total: 0, covered: 0, skipped: 0, pct: 0 }
};
const coverageMapData: CoverageMapData = {};
const fileCoverageData: FileCoverageData = {
path: 'foo',
statementMap: {},
fnMap: {},
branchMap: {},
s: {},
f: {},
b: {}
};
const summary1 = createCoverageSummary(summaryData);
summary1.data;
summary1.branches;
summary1.lines;
summary1.functions;
summary1.statements;
const summary2 = createCoverageSummary(summary1);
const map1 = createCoverageMap(coverageMapData);
map1.data;
const map2 = createCoverageMap(map1);
map2.data;
const fileCoverage1 = createFileCoverage('path/to/foo');
fileCoverage1.data;
const fileCoverage2 = createFileCoverage(fileCoverage1.data);
fileCoverage2.data;
}
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
}));
}
});
},
each: {
statements: 0,
branches: 0,
lines: 0,
functions: 0,
excludes: [],
overrides: {}
}
}
var thresholds = helper.merge({}, defaultThresholds, config.check)
var globalTrackedFiles = getTrackedFiles(coverageMap, thresholds.global.excludes)
var eachTrackedFiles = getTrackedFiles(coverageMap, thresholds.each.excludes)
var globalResults = istanbulLibCoverage.createCoverageSummary()
var eachResults = {}
globalTrackedFiles.forEach(function (f) {
var fileCoverage = coverageMap.fileCoverageFor(f)
var summary = fileCoverage.toSummary()
globalResults.merge(summary)
})
eachTrackedFiles.forEach(function (f) {
var fileCoverage = coverageMap.fileCoverageFor(f)
var summary = fileCoverage.toSummary()
eachResults[f] = summary
})
var coverageFailed = false
function check (name, thresholds, actuals) {
var keys = [
getCoverageSummary(filesOnly) {
const cacheProp = `c_${filesOnly ? 'files' : 'full'}`;
let summary;
if (Object.prototype.hasOwnProperty.call(this, cacheProp)) {
return this[cacheProp];
}
if (!this.isSummary()) {
summary = this.getFileCoverage().toSummary();
} else {
let count = 0;
summary = coverage.createCoverageSummary();
this.getChildren().forEach(child => {
if (filesOnly && child.isSummary()) {
return;
}
count += 1;
summary.merge(child.getCoverageSummary(filesOnly));
});
if (count === 0 && filesOnly) {
summary = null;
}
}
this[cacheProp] = summary;
return summary;
}
}
if (threshold < 0 && threshold * -1 < uncovered) {
passedThreshold = false;
this.log.error("%s: Expected max %s uncovered %s, got %s (%s)",
browser.name, (-1 * threshold), key, uncovered, name);
}
else if (result.pct < threshold) {
passedThreshold = false;
this.log.error("%s: Expected %s% coverage for %s, got %s% (%s)",
browser.name, threshold, key, result.pct, name);
}
});
};
const thresholdConfig = this.config.coverageOptions.threshold;
const globalSummary = istanbulCoverage.createCoverageSummary();
const globalSummaries = this.toSummaries(coverageMap, thresholdConfig.global.excludes);
const fileSummaries = this.toSummaries(coverageMap, thresholdConfig.file.excludes);
Object.keys(globalSummaries).forEach((filename) => {
globalSummary.merge(globalSummaries[filename]);
});
checkThresholds("global", thresholdConfig.global, globalSummary);
Object.keys(fileSummaries).forEach((filename) => {
const relativeFilename = FileUtils.getRelativePath(filename, this.config.karma.basePath);
const thresholds = merge(thresholdConfig.file, this.getFileOverrides(relativeFilename));
checkThresholds(filename, thresholds, fileSummaries[filename]);
});
return passedThreshold;