import { defineConfig } from 'vitest/config'; export default defineConfig({ test: { // Node environment for all tests (server-side CJS modules, no browser APIs needed) environment: 'node', // Global test helpers (describe, it, expect, vi) without per-file imports globals: true, // Run each test file in an isolated module registry so module-level state // (tokenStore cache, config singletons) doesn't leak between files isolate: true, // Give each file its own data directory so tokenStore file I/O doesn't collide setupFiles: ['./tests/setup.js'], // Coverage via V8 (built into Node — no babel transform needed) coverage: { provider: 'v8', reporter: ['text', 'lcov', 'html'], reportsDirectory: './coverage', // Only measure coverage on production source files include: ['server/**/*.js'], exclude: [ 'server/index.js', // entry point with side-effects (process.exit, log streams) 'node_modules/**', 'tests/**', 'coverage/**' ], // Global thresholds only — per-file thresholds are avoided because V8's // coverage counting varies across Node versions (CI consistently reports // ~10-15% lower than local for module-wrapper and require() lines). // The overall numbers reflect that dashboard.js and poller.js are large // untested files; the security-critical files (auth, middleware, utils) // are well-covered by the 115 tests. thresholds: { lines: 25, functions: 12, branches: 12, statements: 25 } } } });