forked from moodlehq/design-system
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.ts
More file actions
65 lines (62 loc) · 1.76 KB
/
vitest.config.ts
File metadata and controls
65 lines (62 loc) · 1.76 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
57
58
59
60
61
62
63
64
65
import { storybookTest } from '@storybook/addon-vitest/vitest-plugin';
import { playwright } from '@vitest/browser-playwright';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { defineConfig } from 'vitest/config';
const dirname =
typeof __dirname !== 'undefined'
? __dirname
: path.dirname(fileURLToPath(import.meta.url));
const isStorybook = process.env.VITEST_STORYBOOK === 'true';
export default defineConfig({
optimizeDeps: {
include: ['react', 'react-dom', 'react/jsx-dev-runtime'],
},
plugins: isStorybook
? [
storybookTest({
configDir: path.resolve(dirname, '.storybook'),
tags: {
include: ['test'],
exclude: ['experimental'],
},
}),
]
: [],
test: {
globals: true,
environment: 'jsdom',
setupFiles: isStorybook
? ['.storybook/vitest.setup.ts']
: ['./tests/setupTests.ts'],
include: !isStorybook
? ['components/**/*.{test,spec}.{js,ts,jsx,tsx}']
: undefined,
exclude: isStorybook
? ['components/**/*.{test,spec}.{js,ts,jsx,tsx}']
: ['**/*.stories.*', '.storybook/**', '**/.storybook/**'],
browser: isStorybook
? {
enabled: true,
headless: true,
provider: playwright({}),
instances: [{ browser: 'chromium' }],
}
: undefined,
coverage: {
provider: 'istanbul',
include: !isStorybook ? ['components/**/*.{ts,tsx,js,jsx}'] : undefined,
exclude: [
'**/*.stories.*',
'.storybook/**',
'**/.storybook/**',
'components/**/*.{test,spec}.{js,ts,jsx,tsx}',
],
watermarks: !isStorybook
? {
statements: [50, 80],
}
: undefined,
},
},
});