-
-
Notifications
You must be signed in to change notification settings - Fork 143
Expand file tree
/
Copy pathvitest.config.e2e.ts
More file actions
64 lines (56 loc) · 1.7 KB
/
Copy pathvitest.config.e2e.ts
File metadata and controls
64 lines (56 loc) · 1.7 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
import * as path from 'node:path';
import * as os from 'node:os';
import * as process from 'node:process';
import { defineConfig } from 'vitest/config';
import { fileURLToPath } from 'node:url';
const timeout = process.env.CI ? 50000 : 30000;
const __dir = path.dirname(fileURLToPath(import.meta.url));
const utilsPath = path.resolve(__dir, 'packages/e2e-tests/testUtils');
// too many threads cause vite-ssr tests to fail randomly, limit to at most 33%
const fractionOfAvailableThreads = (f: number) =>
Math.max(1, Math.floor((os.cpus()?.length || 1) * f));
const numThreads = fractionOfAvailableThreads(1 / 3);
// start with vitest default excludes
const exclude = [
'**/node_modules/**',
'**/dist/**',
'**/cypress/**',
'**/.{idea,git,cache,output,temp}/**'
];
const include = ['./packages/e2e-tests/**/*.spec.[tj]s'];
const isBuildWatch = !!process.env.TEST_BUILD_WATCH;
const buildWatchPatterns = ['./packages/e2e-tests/build-watch/**/*.spec.[tj]s'];
if (isBuildWatch) {
include.length = 0;
include.push(...buildWatchPatterns);
} else {
exclude.push(...buildWatchPatterns);
}
const reporters = ['dot'];
const isGithubActions = !!process.env.GITHUB_ACTIONS;
if (isGithubActions) {
reporters.push('github-actions');
}
export default defineConfig({
resolve: {
alias: {
'~utils': utilsPath
}
},
test: {
include,
exclude,
setupFiles: ['./packages/e2e-tests/vitestSetup.ts'],
globalSetup: ['./packages/e2e-tests/vitestGlobalSetup.ts'],
testTimeout: timeout,
hookTimeout: timeout,
globals: true,
reporters,
onConsoleLog(log) {
if (log.match(/experimental|jit engine|emitted file/i)) return false;
},
minThreads: numThreads,
maxThreads: numThreads,
retry: isGithubActions ? 2 : 0
}
});