feat(09-01): configure Vitest with multi-project setup

- Install Vitest, @vitest/browser, vitest-browser-svelte, @vitest/coverage-v8
- Configure multi-project: client (browser/Playwright) and server (node)
- Add test scripts: test, test:unit, test:unit:watch, test:coverage
- Coverage provider: v8 with autoUpdate thresholds

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Thomas Richter
2026-02-03 23:28:21 +01:00
parent 49e1c90f37
commit a3ef94f572
3 changed files with 696 additions and 3 deletions

View File

@@ -1,7 +1,44 @@
import { sveltekit } from '@sveltejs/kit/vite';
import tailwindcss from '@tailwindcss/vite';
import { playwright } from '@vitest/browser-playwright';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [tailwindcss(), sveltekit()]
plugins: [tailwindcss(), sveltekit()],
test: {
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
include: ['src/**/*.{ts,svelte}'],
exclude: ['src/**/*.test.ts', 'src/**/*.spec.ts'],
thresholds: {
autoUpdate: true
}
},
projects: [
{
extends: true,
test: {
name: 'client',
testTimeout: 5000,
browser: {
enabled: true,
provider: playwright(),
instances: [{ browser: 'chromium' }]
},
include: ['src/**/*.svelte.{test,spec}.{js,ts}'],
setupFiles: ['./vitest-setup-client.ts']
}
},
{
extends: true,
test: {
name: 'server',
environment: 'node',
include: ['src/**/*.{test,spec}.{js,ts}'],
exclude: ['src/**/*.svelte.{test,spec}.{js,ts}']
}
}
]
}
});