Repository navigation
Expand file tree
/
Copy pathvitest.config.ts
More file actions
79 lines (75 loc) · 2.95 KB
/
Copy pathvitest.config.ts
File metadata and controls
79 lines (75 loc) · 2.95 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
import { defineConfig, type UserWorkspaceConfig } from 'vitest/config';
const isCI = Boolean(process.env.CI);
const isWindowsCI = isCI && process.platform === 'win32';
// In CI, emit a Vitest JSON report next to the benchmark harness so the
// "Report parallelism metrics" step can summarize the real gating run.
// execution.json records effective project options: file-based projects do not
// inherit the root pool/isolate options. Keep this path in sync with the metrics step
// in .github/workflows/ci.yml. Locally we keep the default reporter only.
const CI_VITEST_JSON = 'benchmark/ci-test/ci-run/vitest-results.json';
const config: UserWorkspaceConfig = defineConfig({
test: {
pool: 'threads',
isolate: false,
reporters: [
'default',
...(isCI ? [['json', { outputFile: CI_VITEST_JSON }] as ['json', { outputFile: string }]] : []),
...(process.env.CI_TEST_REPORT === '1' ? ['./scripts/ci-reporter.ts'] : []),
...(process.env.CI_COVERAGE_REPORT === '1'
? [['blob', { outputFile: 'benchmark/ci-test/ci-run/blob.json' }] as ['blob', { outputFile: string }]]
: []),
],
// Windows CI is more contention-sensitive than posix, so we cap the thread
// pool. Use the full standard `windows-latest` runner (4 vCPU) instead of the
// previous hard cap of 2; the suite already retries flaky tests (--retry 2).
...(isWindowsCI
? {
maxWorkers: 4,
}
: {}),
projects: [
'packages/*',
'plugins/*',
'tools/create-egg',
'tegg/core/*',
'tegg/plugin/*',
'tegg/standalone/*',
// FIXME: enable this will cause one test file run twice
// {
// extends: true,
// test: {
// include: ['**/test/**/*.test.ts'],
// exclude: ['**/test/fixtures/**', '**/node_modules/**', '**/dist/**'],
// },
// },
],
coverage: {
provider: 'v8',
exclude: ['**/test/**'],
},
hookTimeout: 20000,
testTimeout: 20000,
env: {
// disable tegg plugins by default on unittest, make test speed up
DISABLE_TEGG_PLUGINS: 'true',
// Transpile runtime `import()` of .ts files (egg loader resolving
// fixtures/plugins/app code, and the workspace `src` exports under
// node_modules) with oxc-node — noticeably faster than tsx and it handles
// decorators correctly. Requires @oxc-node/core >= 0.1.0, which fixes the
// earlier "Cannot read properties of undefined (reading 'mode')" crash.
NODE_OPTIONS: '--import=@oxc-node/core/register',
},
// poolOptions: {
// forks: {
// execArgv: [
// // TODO: aop plugin required this flag, otherwise there will be a SyntaxError: Invalid or unexpected token
// '--import=tsx/esm',
// // TODO: TypeScript enum is not supported in strip-only mode
// // '--experimental-transform-types',
// ],
// },
// },
fsModuleCache: true,
},
});
export default config;