How to use istanbul - 10 common examples

To help you get started, we’ve selected a few istanbul examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sugarcrm / sucrose / test / lib / coverage.js View on Github external
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.");
    });
  };
};
github bitovi / testee / lib / server / hooks / coverage.js View on Github external
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);
};
github bitovi / testee / lib / extensions / coverage.js View on Github external
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);
	}
};
github microsoft / vscode-azure-blockchain-ethereum / test / index.ts View on Github external
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
github litleleprikon / socket-io-vscode / test / index.js View on Github external
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
github dlang-vscode / dlang-vscode / test / index.ts View on Github external
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
github maenu / grunt-template-jasmine-istanbul / src / main / js / template.js View on Github external
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;
};
github rschuft / karma-sharding / lib / reporter.js View on Github external
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
  };
github walmartlabs / little-loader / test / func / spec / base.spec.js View on Github external
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);
};
github rvikmanis / redux-fp / test / istanbul.reporter.js View on Github external
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');
    });
  });
};

istanbul

Yet another JS code coverage tool that computes statement, line, function and branch coverage with module loader hooks to transparently add coverage when running tests. Supports all JS coverage use cases including unit tests, server side functional tests

BSD-3-Clause
Latest version published 8 years ago

Package Health Score

52 / 100
Full package analysis