-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.mts
More file actions
99 lines (92 loc) · 2.46 KB
/
Copy pathvitest.config.mts
File metadata and controls
99 lines (92 loc) · 2.46 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { defineConfig, defineWorkspace, mergeConfig } from 'vitest/config';
const dirname =
typeof __dirname !== 'undefined'
? __dirname
: path.dirname(fileURLToPath(import.meta.url));
// 共通のエイリアス設定
const resolveAlias = {
alias: {
'@/app': path.resolve(dirname, './app'),
'@/src': path.resolve(dirname, './src'),
'@/e2e': path.resolve(dirname, './e2e'),
},
};
const sharedConfig = defineConfig({
test: {
exclude: ['node_modules'],
},
resolve: resolveAlias,
});
// Storybookテスト統合は相性が悪いため無効化
// const storybookConfig = defineConfig({
// plugins: [
// storybookTest({
// configDir: path.join(dirname, '.storybook'),
// }),
// ],
// test: {
// testTimeout: 15000,
// globals: true,
// name: 'storybook',
// setupFiles: ['.storybook/vitest.setup.ts'],
// browser: {
// enabled: true,
// headless: true,
// provider: 'playwright',
// },
// },
// resolve: resolveAlias,
// });
const vitestConfig = defineConfig({
test: {
globals: true,
name: 'vitest',
environment: 'jsdom',
setupFiles: ['./src/configs/vitest/vitest-setup.ts'],
include: ['./src/**/*.{test,spec}.{ts,tsx}'], // tsx追加でコンポーネントテスト対応
exclude: ['./src/**/*.stories.{ts,tsx}', './src/test-utils/**/*.{ts,tsx}'], // Storybook・test-utilsは除外
ui: true,
open: true,
env: {
NEXT_PUBLIC_FIREBASE_PROJECT_ID: 'test-project',
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN: 'test-project.firebaseapp.com',
NEXT_PUBLIC_FIREBASE_API_KEY: 'test-api-key',
NEXT_PUBLIC_GTM_ID: 'GTM-TEST',
},
// カバレッジ設定追加
coverage: {
provider: 'v8',
reporter: ['text', 'html', 'lcov'],
exclude: [
'**/*.stories.{ts,tsx}',
'**/test-utils/**',
'**/types/**',
'**/constants/**',
'**/*.d.ts',
'src/lib/firebase*.ts', // Firebase設定は除外
],
thresholds: {
global: {
branches: 60,
functions: 60,
lines: 60,
statements: 60,
},
},
},
},
resolve: resolveAlias,
});
const workspace = defineWorkspace([
// mergeConfig(sharedConfig, storybookConfig),
mergeConfig(sharedConfig, vitestConfig),
]);
export default defineConfig({
test: {
globals: true,
workspace,
},
resolve: resolveAlias,
});