One Double Zero Core

raw JSON →
1.0.2 verified Sat Apr 25 auth: no javascript

A code coverage API for JavaScript aiming at relevance, accuracy, simplicity, flexibility and speed (v1.0.2). It leverages V8's built-in coverage for fast, accurate results without instrumenting code. The API is designed to be minimal and composable, catering to both programmatic use and integration with test runners. Ships TypeScript types. Released under ISC license. Known for being lighter and faster than c8 or Istanbul, but with a different API paradigm.

error TypeError: (0 , _oneDoubleZeroCore.default) is not a function
cause Using default import incorrectly in TypeScript or Babel when module is CJS?
fix
Ensure you use import coverage from 'one-double-zero-core' with ESM and appropriate tsconfig (esModuleInterop: true).
error Error: ENOENT: no such file or directory, open 'path/to/coverage.json'
cause Forgetting to provide output path or calling snapshot before load.
fix
Check that coverage.load() was awaited and options are correct.
breaking API differs from c8/istanbul; no automatic instrumenter.
fix Use explicit Coverage and Instrumenter classes; refer to docs for programmatic usage.
gotcha Must call coverage.load() before tests; otherwise snapshot returns empty.
fix Always await coverage.load() at the start of your test setup.
gotcha Excludes 'node_modules' by default; override if needed.
fix Set exclude: [] to include node_modules (not recommended).
npm install one-double-zero-core
yarn add one-double-zero-core
pnpm add one-double-zero-core

Shows basic usage: initialize coverage with include/exclude patterns, then take snapshot after tests.

import coverage from 'one-double-zero-core';

const { Coverage } = await coverage.load({
  // Paths to cover, e.g., 'src/**/*.js'
  include: ['src/**/*.js'],
  // Exclude patterns
  exclude: ['node_modules']
});

// After your tests run, gather coverage data
const result = await Coverage.takeSnapshot();
console.log('Coverage percentage:', result.summary.coveredLines / result.summary.totalLines * 100);