How to use the istanbul-lib-instrument.readInitialCoverage function in istanbul-lib-instrument

To help you get started, we’ve selected a few istanbul-lib-instrument 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 DefinitelyTyped / DefinitelyTyped / types / istanbul-lib-instrument / istanbul-lib-instrument-tests.ts View on Github external
// instrument without a filename
instrumenter.instrument(code, (error, code) => {
	if (error) {
		error.stack;
	} else {
		code.trim();
	}
});

const cov = instrumenter.lastFileCoverage();
Object.create(cov);

const map = instrumenter.lastSourceMap();
Object.create(map);

const initialCov = readInitialCoverage(code);
initialCov.gcv;

programVisitor(babelTypes);
programVisitor(babelTypes, filename);
programVisitor(babelTypes, filename, { coverageVariable: 'coverage' });
const visitor = programVisitor(babelTypes, filename, { inputSourceMap: sourceMap });

visitor.enter(filename);
const data = visitor.exit(filename);
Object.create(data.fileCoverage);
github istanbuljs / nyc / lib / instrumenters / noop.js View on Github external
instrumentSync (code, filename) {
      const extracted = readInitialCoverage(code)
      if (extracted) {
        this.fileCoverage = extracted.coverageData
      } else {
        this.fileCoverage = null
      }
      return code
    },
    lastFileCoverage () {
github facebookarchive / atom-ide-ui / scripts / initial-coverage.js View on Github external
jsFiles.forEach(file => {
  const src = fs.readFileSync(file);
  if (NodeTranspiler.shouldCompile(src)) {
    const code = nodeTranspiler.transformWithCache(src, file);
    const coverage = libInstrument.readInitialCoverage(code);
    if (coverage != null && coverage.coverageData != null) {
      result[file] = coverage.coverageData;
    }
  }
});

istanbul-lib-instrument

Core istanbul API for JS code coverage

BSD-3-Clause
Latest version published 1 month ago

Package Health Score

81 / 100
Full package analysis