@tracecov/core
@tracecov/core
API coverage tracking for Node.js. Measures which operations, parameters, and JSON Schema keywords (minLength, pattern, enum, ...) your tests exercise against an OpenAPI specification.
Installation
npm install @tracecov/core
Requirements: Node.js >= 18. ESM-only: use import syntax. CommonJS projects must use await import('@tracecov/core').
Supported platforms (prebuilt binaries, installed automatically): Linux x64/arm64 (glibc), macOS x64/arm64, Windows x64.
Quick Start
Load your spec, record the interactions your tests make, and write a report:
npm install @tracecov/core
import { CoverageMap } from '@tracecov/core';
const coverage = CoverageMap.fromPath('openapi.json');
const start = Date.now();
const res = await fetch('https://api.example.com/users');
coverage.record(
{ method: 'GET', url: 'https://api.example.com/users', headers: {} },
{ statusCode: res.status, elapsed: (Date.now() - start) / 1000 },
);
coverage.saveHtmlReport({ outputFile: 'coverage.html' });
Call record() from your HTTP client's interceptor or middleware to avoid repeating it per request. Or let a companion package do it: @tracecov/axios and @tracecov/fetch for HTTP clients, @tracecov/express for server-side capture, and @tracecov/vitest or @tracecov/jest for multi-file coverage in Vitest or Jest.
Documentation
- Integration guide: recording interactions, reports, thresholds, importing HAR/Postman/VCR
- API reference: full
CoverageMapAPI