How to use istanbul-reports - 10 common examples

To help you get started, we’ve selected a few istanbul-reports 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 xwp / wp-foo-bar / tests / merge-coverage.js View on Github external
dir: reportOut,
		defaultSummarizer: 'nested',
		coverageMap,
	} );

	const reportType = Array.isArray( type ) ? type.pop() : type;

	// create an instance of the relevant report class
	const report = istanbulReports.create( reportType );

	// call execute to synchronously create and write the report to disk
	report.execute( context );

	// show the report text summary in console only if the reporter is not a text report.
	if ( ! reportType.includes( 'text' ) ) {
		const text = istanbulReports.create( 'text' );

		text.execute( context );
	}
};
github xwp / wp-foo-bar / tests / merge-coverage.js View on Github external
const generateReport = ( coverageMap, type ) => {
	// create a context for report generation
	const context = libReport.createContext( {
		dir: reportOut,
		defaultSummarizer: 'nested',
		coverageMap,
	} );

	const reportType = Array.isArray( type ) ? type.pop() : type;

	// create an instance of the relevant report class
	const report = istanbulReports.create( reportType );

	// call execute to synchronously create and write the report to disk
	report.execute( context );

	// show the report text summary in console only if the reporter is not a text report.
	if ( ! reportType.includes( 'text' ) ) {
		const text = istanbulReports.create( 'text' );

		text.execute( context );
	}
};
github flaviuse / mern-authentication / client / node_modules / istanbul-api / lib / reporter.js View on Github external
add(fmt) {
        if (this.reports[fmt]) {
            // already added
            return;
        }
        const config = this.config;
        const rptConfig = config.reporting.reportConfig()[fmt] || {};
        rptConfig.verbose = config.verbose;
        try {
            if (this.config.verbose) {
                console.error('Create report', fmt, ' with', rptConfig);
            }
            this.reports[fmt] = libReports.create(fmt, rptConfig);
        } catch (ex) {
            throw inputError.create('Invalid report format [' + fmt + ']');
        }
    },
    /**
github istanbuljs / istanbuljs / packages / istanbul-api / lib / reporter.js View on Github external
add(fmt) {
        if (this.reports[fmt]) {
            // already added
            return;
        }
        const config = this.config;
        const rptConfig = config.reporting.reportConfig()[fmt] || {};
        rptConfig.verbose = config.verbose;
        try {
            if (this.config.verbose) {
                console.error('Create report', fmt, ' with', rptConfig);
            }
            this.reports[fmt] = libReports.create(fmt, rptConfig);
        } catch (ex) {
            throw inputError.create('Invalid report format [' + fmt + ']');
        }
    },
    /**
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
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 monounity / karma-typescript / packages / karma-typescript / src / karma / reporter.ts View on Github external
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 zordius / gulp-jsx-coverage / index.js View on Github external
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 theintern / intern / src / lib / reporters / Coverage.ts View on Github external
if (isCoverageMap(data)) {
      map = data;
    } else {
      map = createCoverageMap(data);
    }

    const transformed = this.executor.sourceMapStore.transformCoverage(map);

    const context = createContext({
      dir: this.directory,
      sourceFinder: transformed.sourceFinder,
      watermarks: this.watermarks
    });
    const tree = summarizers.pkg(transformed.map);
    const report = create(type, this.getReporterOptions());
    tree.visit(report, context);
  }
github streamlink / streamlink-twitch-gui / build / tasks / common / cdp / coverage.js View on Github external
reporters.forEach( ({ name, options }) => {
			const report = reports.create( name, options );
			tree.visit( report, context );
			grunt.log.ok( `Coverage reporter run: ${name}` );
		});
	}

istanbul-reports

istanbul reports

BSD-3-Clause
Latest version published 9 months ago

Package Health Score

83 / 100
Full package analysis

Popular istanbul-reports functions