MCPcopy Index your code
hub / github.com/nodejs/node / setupCoverage

Function setupCoverage

lib/internal/test_runner/coverage.js:598–626  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

596}
597
598function setupCoverage(options) {
599 let originalCoverageDirectory = process.env.NODE_V8_COVERAGE;
600
601 // If NODE_V8_COVERAGE was already specified, convert it to an absolute path
602 // and store it for later. The test runner will use a temporary directory
603 // so that no preexisting coverage files interfere with the results of the
604 // coverage report. Then, once the coverage is computed, move the coverage
605 // files back to the original NODE_V8_COVERAGE directory.
606 originalCoverageDirectory &&= resolve(options.cwd, originalCoverageDirectory);
607
608 const coverageDirectory = mkdtempSync(join(tmpdir(), 'node-coverage-'));
609 const enabled = setupCoverageHooks(coverageDirectory);
610
611 if (!enabled) {
612 return null;
613 }
614
615 internalBinding('profiler').startCoverage();
616
617 // Ensure that NODE_V8_COVERAGE is set so that coverage can propagate to
618 // child processes.
619 process.env.NODE_V8_COVERAGE = coverageDirectory;
620
621 return new TestCoverage(
622 coverageDirectory,
623 originalCoverageDirectory,
624 options,
625 );
626}
627
628function mapRangeToLines(range, lines) {
629 const { startOffset, endOffset, count } = range;

Callers 1

configureCoverageFunction · 0.85

Calls 5

tmpdirFunction · 0.85
setupCoverageHooksFunction · 0.85
resolveFunction · 0.50
mkdtempSyncFunction · 0.50
joinFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…