Oxc Coverage Instrument

July 21, 2026 ยท View on GitHub

CI Coverage Crates.io npm docs.rs MIT License

Istanbul-compatible JavaScript and TypeScript coverage instrumentation built on the Oxc parser.

Instrumentation happens at the AST level through oxc_traverse and oxc_codegen, and the output is checked against istanbul-lib-instrument on a shared fixture corpus, both by count and byte for byte. The workspace also provides the surrounding Istanbul-compatible pipeline: the data model, source-map remapping, V8-to-Istanbul conversion, report summarization, and the text, text-summary, json-summary, lcov, cobertura, and html reporters. It does not claim to port every Istanbul package or reporter.

Install

[dependencies]
oxc_coverage_instrument = "0.11"
npm install oxc-coverage-instrument
cargo install --git https://github.com/fallow-rs/oxc-coverage-instrument oxc_coverage_instrument_cli

Usage

use oxc_coverage_instrument::{instrument, InstrumentOptions};

let source = "function add(a, b) { return a + b; }";
let result = instrument(source, "add.js", &InstrumentOptions::default()).unwrap();

assert_eq!(result.coverage_map.fn_map["0"].name, "add");
println!("{}", result.code);
import { instrument } from 'oxc-coverage-instrument';

const result = instrument(source, 'file.js', { sourceMap: true });
const coverageMap = JSON.parse(result.coverageMap);
oxc-coverage-instrument src/app.js -o dist/app.js --source-map
oxc-coverage-instrument report --format text coverage-final.json

Vitest, vite-plugin-istanbul, and custom Vite or Rollup plugins are covered in the Node.js package README.

Documentation

Compatibility

  • Rust 1.95 or newer, 2024 edition
  • Oxc 0.140.x
  • Istanbul coverage-final.json v3 or newer
  • Node.js 18 or newer, through napi-rs
ProjectAST
istanbul-lib-instrumentBabel
babel-plugin-istanbulBabel
swc-plugin-coverage-instrumentSWC

Contributing

See CONTRIBUTING.md, and AGENTS.md for the workspace layout and the check profiles.

License

MIT