@tracecov/fetch
v0.23.4
Published
Automatic OpenAPI coverage capture for the Fetch API.
Maintainers
Readme
@tracecov/fetch
Automatic OpenAPI coverage capture for fetch. Wraps fetch so every call is recorded into a @tracecov/core coverage map — no record() by hand.
Installation
npm install @tracecov/fetchQuick Start
import { CoverageMap } from '@tracecov/core';
import { instrumentFetch } from '@tracecov/fetch';
const coverage = CoverageMap.fromPath('openapi.json');
const restore = instrumentFetch(coverage); // patches globalThis.fetch
await fetch('https://api.example.com/users');
restore(); // undo the patch, e.g. in afterAll
coverage.saveHtmlReport({ outputFile: 'coverage.html' });wrapFetch(fetch, coverage) returns an instrumented fetch without touching the global. For multi-file coverage in Vitest, see @tracecov/vitest.
