@vitest/istanbul-lib-instrument
v2.1.1
Published
Core istanbul API for JS code coverage
Readme
@vitest/istanbul-lib-instrument
Istanbul instrumenter library. The code is parsed with OXC (via rolldown) and
coverage counters are inserted into the original code with magic-string, so the output keeps the
original formatting, comments and line numbers.
import { createInstrumenter } from "@vitest/istanbul-lib-instrument";
const instrumenter = createInstrumenter({ esModules: true, produceSourceMap: true });
const code = instrumenter.instrumentSync(source, filename, inputSourceMap);
const coverage = instrumenter.lastFileCoverage();
const map = instrumenter.lastSourceMap();