0.23.3 • Published yesterday
@tracecov/vitest
Licence
LicenseRef-TraceCov-Community-1.0
Version
0.23.3
Deps
1
Size
7 kB
Vulns
0
Weekly
0
@tracecov/vitest
Multi-file OpenAPI coverage reporting for Vitest.
Vitest runs each test file in its own worker process, so a single coverage map never sees every file's requests. This plugin gives each worker a map, merges them in the reporter, and writes one report for the whole run. Client-agnostic — pair it with @tracecov/fetch or @tracecov/axios.
Installation
npm install -D @tracecov/vitest
Quick Start
Add the plugin to vitest.config.ts:
import { tracecov } from '@tracecov/vitest';
import { defineConfig } from 'vitest/config';
export default defineConfig({
plugins: [
tracecov({
schema: 'openapi.json',
setup: './tracecov.setup.ts',
report: { html: 'coverage.html' },
thresholds: { operations: 80 },
}),
],
});
Create the setup file it points at, and wire a coverage map to your client:
// tracecov.setup.ts
import { instrumentFetch } from '@tracecov/fetch';
import { collectCoverage } from '@tracecov/vitest/setup';
instrumentFetch(collectCoverage());
Requests are recorded, merged across workers, and written to the configured report(s) when the run ends. A thresholds breach sets a non-zero exit code, so CI fails when coverage drops.