How to use the istanbul-lib-report.summarizers 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 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 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 zordius / gulp-jsx-coverage / index.js View on Github external
message: 'No coverage info! Check your options.src or options.istanbul.exclude to ensure you include proper files'
                }));
            }

            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
                    }));
                }
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 streamlink / streamlink-twitch-gui / build / tasks / common / cdp / coverage.js View on Github external
const dir = grunt.config( "dir.tmp_coverage" );
		const watermarks = grunt.config( "coverage.watermarks" );
		const reporters = grunt.config( "coverage.reporters" );

		const libCoverage = require( "istanbul-lib-coverage" );
		const libReport = require( "istanbul-lib-report" );
		const libSourceMaps = require( "istanbul-lib-source-maps" );
		const reports = require( "istanbul-reports" );

		const map = libCoverage.createCoverageMap( report );
		const sourceMapCache = libSourceMaps.createSourceMapStore();
		map.data = sourceMapCache.transformCoverage(
			libCoverage.createCoverageMap( map.data )
		).map.data;
		const tree = libReport.summarizers.pkg( map );
		const context = libReport.createContext({ dir, watermarks });

		reporters.forEach( ({ name, options }) => {
			const report = reports.create( name, options );
			tree.visit( report, context );
			grunt.log.ok( `Coverage reporter run: ${name}` );
		});
	}
github monounity / karma-typescript / packages / karma-typescript / src / karma / reporter.ts View on Github external
browsers.forEach((browser: any) => {

                    const coverage = that.coverageMap.get(browser);
                    const coverageMap = istanbulCoverage.createCoverageMap();
                    coverageMap.merge(coverage);

                    const sourceMapStore = istanbulSourceMaps.createSourceMapStore();
                    const remappedCoverageMap = sourceMapStore.transformCoverage(coverageMap).map;

                    const tree = istanbulReport.summarizers.pkg(remappedCoverageMap);

                    if (results && config.hasCoverageThreshold && !threshold.check(browser, remappedCoverageMap)) {
                        results.exitCode = 1;
                    }

                    Object.keys(config.reports).forEach((reportType: any) => {

                        const destination = that.getReportDestination(browser, config.reports, reportType);

                        if (destination) {
                            that.log.debug("Writing coverage to %s", destination);
                        }
                        const context = istanbulReport.createContext( { dir: destination } );

                        tree.visit(istanbulReports.create(reportType), context);
                    });
github flaviuse / mern-authentication / client / node_modules / istanbul-api / lib / reporter.js View on Github external
function Reporter(cfg, opts) {
    opts = opts || {};
    this.config = cfg || configuration.loadFile();
    this.dir = path.resolve(this.config.reporting.dir());
    this.reports = {};

    let summarizer = opts.summarizer;
    const s = this.config.reporting.summarizer();

    if (summarizer && typeof summarizer === 'function') {
        this.summarizer = summarizer;
    } else {
        summarizer = libReport.summarizers[s];
        if (!summarizer) {
            throw inputError.create(
                'Invalid summarizer in report config: ' + s
            );
        }
        this.summarizer = summarizer;
    }
}
github istanbuljs / istanbuljs / packages / istanbul-api / lib / reporter.js View on Github external
function Reporter(cfg, opts) {
    opts = opts || {};
    this.config = cfg || configuration.loadFile();
    this.dir = path.resolve(this.config.reporting.dir());
    this.reports = {};

    let summarizer = opts.summarizer;
    const s = this.config.reporting.summarizer();

    if (summarizer && typeof summarizer === 'function') {
        this.summarizer = summarizer;
    } else {
        summarizer = libReport.summarizers[s];
        if (!summarizer) {
            throw inputError.create(
                'Invalid summarizer in report config: ' + s
            );
        }
        this.summarizer = summarizer;
    }
}

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