import { defineConfig } from 'vitest/config'; import { svelte } from '@sveltejs/vite-plugin-svelte'; /** * Vitest config — runs *.svelte.test.ts files under jsdom with the Svelte * plugin, so per-type ParticipantInput / BuilderEditor / ResultsBlock * components in lib/questions/.svelte (or any .svelte component) can * be mounted via @testing-library/svelte. * * Server-side tests (.test.ts under lib/server/) stay on `bun test` per * `bun run test:server`. Component tests live behind `bun run test:components`. * * The runtime split exists because: * 1. Bun test doesn't apply `browser` export conditions when resolving ESM, * so it picks Svelte's `index-server.js` and @testing-library/svelte's * mount() throws lifecycle_function_unavailable. * 2. Vitest reuses the existing svelte vite plugin; no extra runtime split. * * Both runners share the same expect()/describe()/test() API surface, so * component tests look identical in spirit to the server-side ones. */ export default defineConfig({ plugins: [svelte({ hot: false })], resolve: { conditions: ['browser'], }, test: { environment: 'jsdom', include: ['src/**/*.svelte.test.ts'], setupFiles: ['./src/test-setup/vitest.ts'], globals: false, }, });