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']
	},
	resolve: {
		alias: {
			$lib: new URL('./src/lib', import.meta.url).pathname
		}
	}
});
