Files
collective-lists/apps/web/vitest.config.ts
Oier Bravo Urtasun f01dc21e74 feat(fase-16): add Spinner component + unit tests
Fase 16.1 — reusable inline loading indicator. SVG circle with
stroke-dasharray + Tailwind animate-spin (respects motion-reduce).
Sizes: sm=16, md=24, lg=40. Inherits currentColor so it plays nicely
with the Fase 9 theme tokens. Wrapper has role=status + aria-live=polite
and an sr-only m.loading() label (no new Paraglide strings).

vitest.config: resolve.conditions=['browser'] + inline svelte so the
Svelte 5 mount() API resolves to index-client.js instead of the server
entry. Without it the new Spinner.test throws lifecycle_function_unavailable.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 13:39:40 +02:00

38 lines
1.1 KiB
TypeScript

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
}
}
});