Repository navigation
Expand file tree
/
Copy pathvitest.config.ts
More file actions
56 lines (53 loc) · 2.05 KB
/
Copy pathvitest.config.ts
File metadata and controls
56 lines (53 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { storybookTest } from '@storybook/addon-vitest/vitest-plugin';
import { playwright } from '@vitest/browser-playwright';
import { defineConfig } from 'vitest/config';
import { litCssPlugin } from './litcss';
// Storybook-driven tests: every story runs as a test in a real browser, with
// its `play` function as an interaction test and the a11y addon running axe.
// v8 coverage only instruments Chromium, so a --coverage run is Chromium-only;
// a plain `vitest` run adds Firefox and WebKit for cross-browser confidence.
// CI runs the coverage (Chromium) pass and a `--project=firefox --project=webkit`
// pass separately, so no engine runs twice. (Visual regression is a separate
// run — see vitest.visual.config.ts.)
const withCoverage = process.argv.includes('--coverage');
export default defineConfig({
// litCssPlugin transforms component `*.css` imports; the Storybook build/dev
// server picks it up from vite.config.ts, but this Vitest run doesn't load
// that config, so it registers its own (see litcss.ts — once per pipeline).
plugins: [litCssPlugin(), storybookTest({ configDir: '.storybook' })],
// The run logs "Multiple versions of Lit loaded" — a known upstream Storybook
// bug (storybookjs/storybook#31507), dev/test-only and harmless.
test: {
browser: {
enabled: true,
headless: true,
provider: playwright(),
instances: withCoverage
? [{ browser: 'chromium' }]
: [
{ browser: 'chromium' },
{ browser: 'firefox' },
{ browser: 'webkit' },
],
},
coverage: {
provider: 'v8',
include: ['src/**'],
exclude: [
'src/generated/**',
'src/**/*.stories.ts',
'src/**/index.ts',
'src/index.ts',
'src/react/**',
],
// A regression floor just under current coverage; ratchet up as the
// suite grows. Keeping it close to actual is what catches slow erosion.
thresholds: {
statements: 94,
lines: 96,
functions: 95,
branches: 78,
},
},
},
});