npm.io
0.23.3 • Published yesterday

@tracecov/core

Licence
LicenseRef-TraceCov-Community-1.0
Version
0.23.3
Deps
0
Size
48 kB
Vulns
0
Weekly
0

npm npm downloads Node.js License

@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

Keywords