// Vitest configuration for the JellyTau frontend suite. // // TRACES: | DR-215 import { defineConfig } from "vitest/config"; import { svelte } from "@sveltejs/vite-plugin-svelte"; import { resolve } from "path"; export default defineConfig({ plugins: [svelte({ hot: !process.env.VITEST })], test: { globals: true, environment: "jsdom", setupFiles: ["./src/test/setup-globals.ts", "./src/test/setup.ts"], // `scripts/` is included so build tooling (the traceability coverage // engine) is covered by the normal suite rather than only by CI. include: ["src/**/*.{test,spec}.{js,ts}", "scripts/**/*.{test,spec}.{js,ts}"], coverage: { provider: "v8", reporter: ["text", "json", "html"], exclude: ["node_modules/", "src/test/", "**/*.test.ts", "**/*.spec.ts", "src-tauri/"], // RATCHET POLICY — these numbers only ever go UP. // // Same rule as MIN_THRESHOLD in .gitea/workflows/traceability-check.yml: // they sit a few points under what the suite actually achieves, so // deleting a test or landing a large untested module trips the gate, while // ordinary churn does not. Raise them when coverage rises durably. Never // lower one to make a red build pass — write the missing test instead. // // Measured at the time of writing (`bun run test:coverage`): // statements 54.58 · branches 48.70 · functions 49.56 · lines 55.13 // // The absolute figures are held down by `.svelte` components, which are // largely untested by design here — the project's pattern is to extract // the logic into a plain `.ts` module (episodeStrip.ts, TrackList.logic.ts) // and test that. Those extracted modules sit far higher. thresholds: { statements: 51, branches: 45, functions: 46, lines: 52, }, }, }, resolve: { conditions: ["browser"], alias: { $lib: resolve(__dirname, "./src/lib"), "$lib/": resolve(__dirname, "./src/lib/"), "$app/environment": resolve(__dirname, "./src/test/mocks/app-environment.ts"), "$app/navigation": resolve(__dirname, "./src/test/mocks/app-navigation.ts"), "$app/stores": resolve(__dirname, "./src/test/mocks/app-stores.ts"), }, }, });