Skip to content

V8 vs Istanbul ​

For Node.js or Chromium, prefer V8 collection: it does not modify the code under test. To collect JavaScript coverage in Firefox or WebKit, use Istanbul instrumentation.

Collection and reporting are separate choices. If your tooling requires an Istanbul report, MCR can convert V8 input without instrumenting the code again. See both report formats generated from the same data.

FeatureIstanbul → Istanbul reportV8 → V8 reportV8 → Istanbul report
Coverage dataIstanbul (Object)V8 (Array)V8 (Array)
OutputIstanbul reportsV8 reportsIstanbul reports
- Bytes❌✅❌
- Statements✅✅✅
- Branches✅✅✅
- Functions✅✅✅
- Lines✅✅✅
- Execution counts✅✅✅
CSS coverage❌✅✅

For minified output, prefer V8's native coverage ranges. Mapping back to original sources still requires a matching, sufficiently precise sourcemap. If results look wrong, compare against an unminified build.

Choosing a collection method ​

V8: No instrumentation ​

  • Strengths: Collect coverage directly from the runtime without modifying the tested code.
  • Tradeoffs: Requires a V8 runtime with a coverage interface, such as Node.js or Chromium. Compiled or bundled code needs matching sourcemaps to map coverage back to original sources.

See V8 collection, Sourcemaps and debugging and V8 coverage data.

Istanbul: Cross-engine collection ​

  • Strengths: Does not depend on browser-specific native coverage APIs, making it suitable for cross-engine JavaScript tests.
  • Tradeoffs: Requires instrumentation during the build or test preparation, and tests must run that instrumented code, adding configuration and execution overhead.

Instrumentation Issues

Instrumentation typically relies on plugins or transformation steps compatible with your build tool. Established setups such as Webpack + Babel have mature integrations, but support varies across build tools; newer tools may not have a ready-to-use instrumentation plugin.

Working with plain JavaScript does not guarantee the same setup works with TypeScript, Vue single-file components or React JSX/TSX. Check compatibility with syntax transforms, plugin order and the sourcemap chain; additional configuration or custom transformations may be needed.

Instrumentation adds counters and helper code for statements, branches and functions, then updates those counters at runtime. Large numbers of instrumentation points can substantially increase code size and may affect loading and execution performance, especially on frequently executed paths. The overhead depends on the instrumentation scope and workload.

See Istanbul collection for build integrations.

Use MCR native reports ​

Where supported, MCR recommends native V8 coverage data with its native v8 report, without instrumentation or conversion to Istanbul. It preserves the Bytes metric and can display CSS coverage collected through Chromium browser / CDP APIs.

V8 has supported native JavaScript coverage since 2017. See this article for background.

For Node.js tests, see mcr test; for browsers, see Playwright collection.