forked from zhuanggenhua/BoardGame
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.ts
More file actions
69 lines (67 loc) · 2.59 KB
/
Copy pathvitest.config.ts
File metadata and controls
69 lines (67 loc) · 2.59 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
import { defineConfig } from 'vitest/config';
import path from 'path';
import { fileURLToPath } from 'url';
const workspaceRoot = fileURLToPath(new URL('.', import.meta.url));
const rootSetupFile = path.resolve(workspaceRoot, 'vitest.setup.ts');
const apiSetupFile = path.resolve(workspaceRoot, 'apps/api/test/vitest.setup.ts');
export default defineConfig({
server: {
fs: {
strict: false,
},
},
resolve: {
alias: {
'@locales': path.resolve(workspaceRoot, 'public/locales'),
},
},
esbuild: {
// Vitest 默认的 esbuild JSX 转换会走 classic runtime(React.createElement),
// 在未显式 import React 的 TSX 测试里会触发 “React is not defined”。
// 统一切换到 automatic runtime。
jsx: 'automatic',
jsxImportSource: 'react',
tsconfigRaw: {
compilerOptions: {
experimentalDecorators: true,
emitDecoratorMetadata: true,
},
},
},
test: {
globals: true,
environment: 'jsdom',
include: [
'src/core/**/__tests__/**/*.test.{ts,tsx}',
'src/components/**/__tests__/**/*.test.{ts,tsx}',
'src/api/**/__tests__/**/*.test.{ts,tsx}',
'src/hooks/**/__tests__/**/*.test.{ts,tsx}',
'src/lib/**/__tests__/**/*.test.{ts,tsx}',
'src/shared/**/__tests__/**/*.test.{ts,tsx}',
'src/games/**/__tests__/**/*.test.{ts,tsx}',
'src/engine/**/__tests__/**/*.test.{ts,tsx}',
'src/server/**/__tests__/**/*.test.{ts,tsx}',
'src/ugc/**/__tests__/**/*.test.{ts,tsx}',
'src/pages/**/__tests__/**/*.test.{ts,tsx}',
'apps/api/test/**/*.test.{ts,tsx}',
'apps/api/test/**/*.e2e-spec.ts',
],
exclude: [
// 排除审计测试(只在 npm run test:games:audit 时运行)
'**/*audit*.test.{ts,tsx}',
'**/*Audit*.test.{ts,tsx}',
// 排除属性测试(只在 npm run test:games:audit 时运行)
'**/*.property.test.{ts,tsx}',
// 排除调试测试
'**/*debug*.test.{ts,tsx}',
'**/*Debug*.test.{ts,tsx}',
// 默认排除
'**/node_modules/**',
'**/dist/**',
'**/.{idea,git,cache,output,temp}/**',
],
testTimeout: 180000,
hookTimeout: 180000, // 首次拉起 mongodb-memory-server 可能需要下载/解压二进制,60 秒不够稳定。
setupFiles: [rootSetupFile, apiSetupFile],
},
});