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.
Common errors
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.
Warnings
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).
Install
npm install one-double-zero-core yarn add one-double-zero-core pnpm add one-double-zero-core Imports
- default wrong
import { oneDoubleZeroCore } from 'one-double-zero-core'correctimport oneDoubleZeroCore from 'one-double-zero-core' - Coverage wrong
import Coverage from 'one-double-zero-core'correctimport { Coverage } from 'one-double-zero-core' - Instrumenter wrong
import Instrumenter from 'one-double-zero-core'correctimport { Instrumenter } from 'one-double-zero-core' - commonjs require wrong
const { oneDoubleZeroCore } = require('one-double-zero-core')correctconst oneDoubleZeroCore = require('one-double-zero-core')
Quickstart
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);