npm install -D vitest @vitest/coverage-v8
Organize tests with factories, custom matchers, and a proper vitest config.
1 import { defineConfig } from 'vitest/config'; 2 import { resolve } from 'path'; 3 4 export default defineConfig({ 5 test: { 6 globals: true, 7 environment: 'node', 8 setupFiles: ['./tests/setup.ts'], 9 coverage: { 10 provider: 'v8', 11 reporter: ['text', 'html', 'lcov'], 12 thresholds: { lines: 80, functions: 80, branches: 70 }, 13 exclude: ['node_modules', 'dist', 'tests/**', '**/*.test.ts'], 14 }, 15 alias: { '@': resolve(__dirname, 'src') }, 16 }, 17 });
vitest runs with 80%+ coverage threshold; factories used across tests; custom matchers typed
Sign in to share your feedback and join the discussion.