One Double Zero

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

One Double Zero is a code coverage tool focusing on relevance, accuracy, simplicity, flexibility, and speed. It offers a CLI tool named 'odz' that wraps any command to collect V8-based coverage data. As of version 1.1.1, it is actively maintained with frequent releases. Unlike other coverage tools like Istanbul or c8, One Double Zero aims for minimal configuration and high precision by leveraging native V8 coverage. It ships TypeScript types and supports both ESM and CommonJS.

error Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
cause Using CommonJS require() to load the ESM-only package.
fix
Change to import statement or use dynamic import().
error TypeError: Cannot destructure property 'runCoverage' of 'undefined' or 'null'
cause Using destructuring from default import instead of named import.
fix
Use import { runCoverage } from 'one-double-zero' instead of import odz from 'one-double-zero' then destructure.
error Error: ENOENT: no such file or directory, open 'coverage.json'
cause The output file path does not exist or the process lacks write permissions.
fix
Ensure the output directory exists or use an absolute path with existing directory.
breaking v1.0.0 changed from CJS to ESM-only. require() will throw ERR_REQUIRE_ESM.
fix Use import syntax or dynamic import().
gotcha When using programmatic API, the 'include' pattern must be absolute or relative to process.cwd(). Relative paths without leading './' may not match.
fix Use absolute paths or prefix relative paths with './'.
deprecated The .odzrc config file format changed in v1.1.0. Old 'exclude' key renamed to 'coverageExclude'.
fix Update config to use 'coverageExclude' instead of 'exclude'.
npm install one-double-zero
yarn add one-double-zero
pnpm add one-double-zero

Demonstrates CLI usage and programmatic API to collect V8 coverage data with include/exclude patterns.

// Install globally
npm i -g one-double-zero

// Run a command with coverage
odz node my-test.js

// Programmatic usage
import { runCoverage } from 'one-double-zero';

const result = await runCoverage({
  command: 'node',
  args: ['my-test.js'],
  include: ['src/**/*.js'],
  exclude: ['node_modules']
});

console.log(result.lines); // e.g., { covered: 80, total: 100 }