feat(test): add Istanbul browser coverage via standalone client config
Vitest 4 silently ignores per-project coverage overrides in test.projects, so a standalone vitest.client-coverage.config.ts provides the root-level Istanbul coverage block that Vitest actually honours. Root vite.config.ts retains the v8 coverage block (reportsDirectory: coverage/server) for the server project. The client config writes to coverage/client and instruments all .svelte and .svelte.ts files. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -46,6 +46,7 @@ export default defineConfig({
|
|||||||
coverage: {
|
coverage: {
|
||||||
provider: 'v8',
|
provider: 'v8',
|
||||||
reporter: ['text', 'lcov'],
|
reporter: ['text', 'lcov'],
|
||||||
|
reportsDirectory: 'coverage/server',
|
||||||
// Measure utility and server-side logic only. Svelte components run
|
// Measure utility and server-side logic only. Svelte components run
|
||||||
// in the browser project and are excluded here. Browser-only TS files
|
// in the browser project and are excluded here. Browser-only TS files
|
||||||
// (actions, hooks, domain-specific UI state) are also excluded.
|
// (actions, hooks, domain-specific UI state) are also excluded.
|
||||||
|
|||||||
46
frontend/vitest.client-coverage.config.ts
Normal file
46
frontend/vitest.client-coverage.config.ts
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
import { paraglideVitePlugin } from '@inlang/paraglide-js';
|
||||||
|
import devtoolsJson from 'vite-plugin-devtools-json';
|
||||||
|
import tailwindcss from '@tailwindcss/vite';
|
||||||
|
import { defineConfig } from 'vitest/config';
|
||||||
|
import { playwright } from '@vitest/browser-playwright';
|
||||||
|
import { sveltekit } from '@sveltejs/kit/vite';
|
||||||
|
|
||||||
|
// Standalone config for browser-project Istanbul coverage.
|
||||||
|
// Uses a dedicated root-level coverage block because Vitest 4 ignores
|
||||||
|
// per-project coverage overrides inside test.projects.
|
||||||
|
export default defineConfig({
|
||||||
|
optimizeDeps: {
|
||||||
|
include: ['pdfjs-dist', '@tiptap/core', '@tiptap/starter-kit', '@tiptap/extension-mention']
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
tailwindcss(),
|
||||||
|
sveltekit(),
|
||||||
|
devtoolsJson(),
|
||||||
|
paraglideVitePlugin({
|
||||||
|
project: './project.inlang',
|
||||||
|
outdir: './src/lib/paraglide'
|
||||||
|
})
|
||||||
|
],
|
||||||
|
test: {
|
||||||
|
expect: { requireAssertions: true },
|
||||||
|
browser: {
|
||||||
|
enabled: true,
|
||||||
|
provider: playwright(),
|
||||||
|
instances: [{ browser: 'chromium', headless: true }],
|
||||||
|
screenshotDirectory: 'test-results/screenshots',
|
||||||
|
screenshotFailures: true
|
||||||
|
},
|
||||||
|
include: ['src/**/*.svelte.{test,spec}.{js,ts}'],
|
||||||
|
exclude: ['src/lib/server/**'],
|
||||||
|
coverage: {
|
||||||
|
provider: 'istanbul',
|
||||||
|
reporter: ['text', 'lcov'],
|
||||||
|
reportsDirectory: 'coverage/client',
|
||||||
|
include: ['src/**/*.svelte', 'src/**/*.svelte.ts'],
|
||||||
|
exclude: ['src/lib/paraglide/**', 'src/lib/generated/**', 'src/hooks/**', '**/__mocks__/**'],
|
||||||
|
thresholds: {
|
||||||
|
branches: 80
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user