-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathvitest.config.ts
More file actions
58 lines (55 loc) · 1.66 KB
/
vitest.config.ts
File metadata and controls
58 lines (55 loc) · 1.66 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
import { defineConfig } from 'vitest/config';
import { loadEnv } from 'vite';
export default defineConfig(({ mode }) => {
// Load environment variables
const env = loadEnv(mode || 'test', process.cwd(), '');
// Get environment variables from either source
const projectId =
process.env.VITE_CI_TEST_GT_PROJECT_ID || env.VITE_CI_TEST_GT_PROJECT_ID;
const apiKey =
process.env.VITE_CI_TEST_GT_API_KEY || env.VITE_CI_TEST_GT_API_KEY;
return {
test: {
// Enable parallel execution
pool: 'threads',
poolOptions: {
threads: {
// Use more workers for better parallelization
minThreads: 2,
maxThreads: 4,
},
},
// Run tests in parallel (default is true, but being explicit)
fileParallelism: true,
// Enable concurrent test execution within files
sequence: {
concurrent: true,
},
// Set reasonable timeout for all tests
testTimeout: 15000,
// Proper test isolation to prevent mock interference
isolate: true,
// Environment setup
environment: 'node',
// Globals for easier test writing
globals: true,
// Load environment variables from .env files
env: {
...env,
// Suppress GT logger output during tests for cleaner output
_GT_LOG_LEVEL: 'off',
// Pass environment variables directly to test environment
...(projectId && { VITE_CI_TEST_GT_PROJECT_ID: projectId }),
...(apiKey && { VITE_CI_TEST_GT_API_KEY: apiKey }),
},
reporters: [
[
'default',
{
summary: true,
},
],
],
},
};
});