import { defineConfig } from 'vitest/config'; import { playwright } from '@vitest/browser-playwright'; import { sveltekit } from '@sveltejs/kit/vite'; import tailwindcss from '@tailwindcss/vite'; // Use system chromium if PLAYWRIGHT_CHROMIUM_PATH is set (for CI with nixpkgs) const chromiumPath = process.env.PLAYWRIGHT_CHROMIUM_PATH; // Skip browser tests in CI (set SKIP_BROWSER_TESTS=1) const skipBrowserTests = process.env.SKIP_BROWSER_TESTS === '1'; export default defineConfig({ plugins: [tailwindcss(), sveltekit()], ssr: { // Externalize native libsql modules - they can't be bundled external: ['libsql', '@libsql/linux-x64-gnu', '@libsql/linux-x64-musl'] }, test: { expect: { requireAssertions: true }, projects: [ // Only include browser project if not skipping ...(skipBrowserTests ? [] : [ { extends: './vite.config.ts', test: { name: 'client', browser: { enabled: true, provider: playwright({ launchOptions: chromiumPath ? { executablePath: chromiumPath, args: ['--no-sandbox', '--disable-setuid-sandbox'] } : {} }), instances: [{ browser: 'chromium' as const, headless: true }] }, include: ['src/**/*.svelte.{test,spec}.{js,ts}'], exclude: ['src/lib/server/**'] } } ]), { extends: './vite.config.ts', test: { name: 'server', environment: 'node', include: ['src/**/*.{test,spec}.{js,ts}'], exclude: ['src/**/*.svelte.{test,spec}.{js,ts}'] } } ] } });