How to use the istanbul-lib-report.createContext function in istanbul-lib-report

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 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 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 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()
    }
github Eywek / v8-coverage / src / report.js View on Github external
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)
    })
  }
}
github laggingreflex / mochista / istanbul / report / reporter.js View on Github external
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
    )
  );
};
github flaviuse / mern-authentication / client / node_modules / istanbul-api / lib / reporter.js View on Github external
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 => {
github chialab / rna-cli / lib / TestRunners / TestRunner.js View on Github external
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);
    }
}
github istanbuljs / nyc / index.js View on Github external
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()
github facebook / jest / scripts / mapCoverage.js View on Github external
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)
);

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