import { defineConfig } from 'vitest/config'; import { svelte } from '@sveltejs/vite-plugin-svelte'; /** * Vitest config for unit tests in apps/web. * * Uses jsdom so IndexedDB shim (fake-indexeddb) works, and loads the Svelte * plugin so we can import .svelte files from `$lib` if needed. Playwright E2E * lives alongside in `tests/e2e/*` and is driven by playwright.config.ts — * Vitest is told to ignore those paths. */ export default defineConfig({ plugins: [svelte()], test: { environment: 'jsdom', globals: true, include: ['src/**/*.test.ts'], exclude: ['tests/**', 'node_modules/**', '.svelte-kit/**'], setupFiles: ['./vitest.setup.ts'], // Force Svelte to load its browser entry (index-client.js) instead of // the server entry — `mount()` only exists on the client. Without this // any test that mounts a Svelte 5 component throws // `lifecycle_function_unavailable`. jsdom + the `browser` condition is // the canonical Svelte 5 unit-test setup. server: { deps: { inline: [/^svelte/] } } }, resolve: { conditions: ['browser'], alias: { $lib: new URL('./src/lib', import.meta.url).pathname } } });