How to use istanbul-lib-report - 10 common examples

To help you get started, we’ve selected a few istanbul-lib-report 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 itchio / itch / src / unit-tests / run-unit-tests.ts View on Github external
printDurations(zopf.testDurations, msg);

        const libCoverage = require("istanbul-lib-coverage");
        let map = libCoverage.createCoverageMap(global["__coverage__"]);

        const libSourceMaps = require("istanbul-lib-source-maps");
        const sourceMapCache = libSourceMaps.createSourceMapStore();

        map = sourceMapCache.transformCoverage(map).map;

        const libReport = require("istanbul-lib-report");
        const context = libReport.createContext({ dir: "coverage" });

        const reports = require("istanbul-reports");

        const tree = libReport.summarizers.pkg(map);

        // print text-lcov report to coverage.lcov file
        tree.visit(reports.create("lcov"), context);

        let finishedCoverageAt = Date.now();
        console.log(
          `coverage took ${(finishedCoverageAt - finishedAt).toFixed(2)}ms`
        );

        if (harness._exitCode === 0) {
          console.log(chalk.green("[ OK ]"));
        } else {
          console.log(chalk.red("[FAIL]"));
        }
        resolve(harness._exitCode);
      });
github karma-runner / karma-coverage / lib / reporter.js View on Github external
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)
        })
      })
github flaviuse / mern-authentication / client / node_modules / istanbul-api / lib / config.js View on Github external
statements: 0,
                lines: 0,
                branches: 0,
                functions: 0,
                excludes: [] // Currently list of files (root + path). For future, extend to patterns.
            },
            each: {
                statements: 0,
                lines: 0,
                branches: 0,
                functions: 0,
                excludes: []
            }
        }
    };
    ret.reporting.watermarks = libReport.getDefaultWatermarks();
    ret.reporting['report-config'] = {};
    return ret;
}
github karma-runner / karma-coverage / lib / reporter.js View on Github external
// Instance variables
  // ------------------

  this.adapters = []

  // Options
  // -------

  var config = rootConfig.coverageReporter || {}
  var basePath = rootConfig.basePath
  var reporters = config.reporters
  var sourceMapStore = globalSourceMapStore.get(basePath)
  var includeAllSources = config.includeAllSources === true

  if (config.watermarks) {
    config.watermarks = helper.merge({}, istanbulLibReport.getDefaultWatermarks(), config.watermarks)
  }

  if (!helper.isDefined(reporters)) {
    reporters = [config]
  }

  var coverageMaps

  function normalize (key) {
    // Exclude keys will always be relative, but covObj keys can be absolute or relative
    var excludeKey = isAbsolute(key) ? path.relative(basePath, key) : key
    // Also normalize for files that start with `./`, etc.
    excludeKey = path.normalize(excludeKey)

    return excludeKey
  }
github istanbuljs / istanbuljs / packages / istanbul-api / lib / config.js View on Github external
statements: 0,
                lines: 0,
                branches: 0,
                functions: 0,
                excludes: [] // Currently list of files (root + path). For future, extend to patterns.
            },
            each: {
                statements: 0,
                lines: 0,
                branches: 0,
                functions: 0,
                excludes: []
            }
        }
    };
    ret.reporting.watermarks = libReport.getDefaultWatermarks();
    ret.reporting['report-config'] = {};
    return ret;
}
github SonarSource / sonarlint-vscode / test / coverage.ts View on Github external
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));
}
github embark-framework / embark / packages / stack / test-runner / src / lib / index.js View on Github external
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);
  }
github embark-framework / embark / packages / stack / test-runner / src / lib / index.js View on Github external
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);
  }
github SonarSource / sonarlint-vscode / test / coverage.ts View on Github external
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));
}
github splunk / splunk-sdk-javascript / node_modules / nyc / index.js View on Github external
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()
    }

istanbul-lib-report

Base reporting library for istanbul

BSD-3-Clause
Latest version published 1 year ago

Package Health Score

80 / 100
Full package analysis