// Copyright (c) 2026 Gordon Bolton. MIT License. import { defineConfig } from 'vitest/config'; export default defineConfig({ test: { // 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'], // Environment configuration based on test type environmentMatchGlobs: [ // Server tests use node environment (must come first - more specific) ['tests/unit/**/*.js', 'node'], ['tests/integration/**/*.js', 'node'], // Frontend tests need jsdom for DOM APIs (broader pattern comes last) ['tests/frontend/**/*.js', 'jsdom'] ], // 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). // Thresholds updated after adding integration tests for dashboard.js, // emby.js, sonarr.js, radarr.js, and sabnzbd.js. The SSE /stream // endpoint and poller.js remain untested so thresholds are set // conservatively to avoid CI flap from V8 coverage variance. thresholds: { lines: 55, functions: 55, branches: 40, statements: 55 } } } });