Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.reportAll = function() {
let reporter = new istanbul.Reporter();
reporter.addAll(["text"]);
console.log("Cummulative Coverage Report:");
reporter.write(accumulator, sync, function() {
// console.log("Cummulative report generated.");
});
};
};
module.exports = function (server, coverageObject) {
// TODO html-cov etc.
var report = istanbul.Report.create('text');
var collector = new istanbul.Collector();
collector.add(coverageObject);
report.writeReport(collector);
};
var hook = exports.hook = function (server, coverageObject) {
var config = server.config.coverage;
if(config) {
// TODO html-cov etc.
var report = istanbul.Report.create('text');
var collector = new istanbul.Collector();
collector.add(coverageObject);
report.writeReport(collector);
}
};
public setupCoverage(): void {
// Set up Code Coverage, hooking require so that instrumented code is returned
const self = this;
self.instrumenter = new istanbul.Instrumenter({ coverageVariable: self.coverageVar });
const sourceRoot = paths.join(self.testsRoot, self.options.relativeSourcePath);
// Glob source files
const srcFiles = glob.sync('**/**.js', {
cwd: sourceRoot,
ignore: self.options.ignorePatterns,
});
// Create a match function - taken from the run-with-cover.js in istanbul.
const decache = require('decache');
const fileMap: any = {};
srcFiles.forEach((file) => {
const fullPath = paths.join(sourceRoot, file);
fileMap[fullPath] = true;
// On Windows, extension is loaded pre-test hooks and this mean we lose
setupCoverage() {
// Set up Code Coverage, hooking require so that instrumented code is returned
const self = this;
self.instrumenter = new istanbul.Instrumenter({ coverageVariable: self.coverageVar });
const sourceRoot = paths.join(self.testsRoot, self.options.relativeSourcePath);
// Glob source files
const srcFiles = glob.sync('**/**.js', {
cwd: sourceRoot,
ignore: self.options.ignorePatterns,
});
// Create a match function - taken from the run-with-cover.js in istanbul.
const decache = require('decache');
const fileMap = {};
srcFiles.forEach((file) => {
const fullPath = paths.join(sourceRoot, file);
fileMap[fullPath] = true;
// On Windows, extension is loaded pre-test hooks and this mean we lose
// our chance to hook the Require call. In order to instrument the code
// we have to decache the JS file so on next load it gets instrumented.
// This doesn"t impact tests, but is a concern if we had some integration
public setupCoverage(): void {
// Set up Code Coverage, hooking require so that instrumented code is returned
let self = this;
self.instrumenter = new istanbul.Instrumenter({ coverageVariable: self.coverageVar });
let sourceRoot = paths.join(self.testsRoot, self.options.relativeSourcePath);
// Glob source files
let srcFiles = glob.sync("**/**.js", {
cwd: sourceRoot,
ignore: self.options.ignorePatterns,
});
// Create a match function - taken from the run-with-cover.js in istanbul.
let decache = require("decache");
let fileMap = {};
srcFiles.forEach((file) => {
let fullPath = paths.join(sourceRoot, file);
fileMap[fullPath] = true;
// On Windows, extension is loaded pre-test hooks and this mean we lose
var instrument = function (source, tmp) {
var instrumenter = new istanbul.Instrumenter();
var instrumentedSourceText = instrumenter.instrumentSync(
grunt.file.read(source), source);
var instrumentedSource = source;
// don't try to write "C:" as part of a folder name on Windows
if (process.platform === 'win32') {
instrumentedSource = instrumentedSource.replace(/^([a-z]):/i, '$1');
}
instrumentedSource = path.join(tmp, instrumentedSource);
grunt.file.write(instrumentedSource, instrumentedSourceText);
return instrumentedSource;
};
this.onBrowserStart = function (browser) {
if (!collectors[browser[aggregator]]) { // ADDED BY KARMA-SHARDING
collectors[browser[aggregator]] = new istanbul.Collector(); // CHANGE MADE BY KARMA-SHARDING
if (!includeAllSources) return;
collectors[browser[aggregator]].add(coverageMap.get()); // CHANGE MADE BY KARMA-SHARDING
} // ADDED BY KARMA-SHARDING
};
var _covered = function (filePath) {
var fileName = path.relative(PROJECT_ROOT, filePath);
var code = fs.readFileSync(filePath);
var instrumenter = new istanbul.Instrumenter();
return instrumenter.instrumentSync(code.toString(), fileName);
};
module.exports = function (runner) {
const collector = new instanbul.Collector();
const reporter = new instanbul.Reporter();
new MochaSpecReporter(runner);
runner.on('end', function () {
collector.add(global.__coverage__);
reporter.addAll(['json', 'lcovonly']);
reporter.write(collector, true, function () {
process.stdout.write('report generated');
});
});
};