-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathvitest.node.config.ts
More file actions
104 lines (101 loc) · 3.38 KB
/
vitest.node.config.ts
File metadata and controls
104 lines (101 loc) · 3.38 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
100
101
102
103
104
import { defineConfig } from 'vitest/config'
const testMode = process.env.TEST_MODE
if (
testMode !== 'unit' &&
testMode !== 'integration' &&
testMode !== 'tls' &&
testMode !== 'common' &&
testMode !== 'common-integration' &&
testMode !== 'all'
) {
throw new Error(
`Unsupported TEST_MODE: [${testMode}]. Supported modes are: unit, integration, tls, common, common-integration, all.`,
)
}
const collections = {
unit: [
'packages/client-node/__tests__/unit/*.test.ts',
'packages/client-node/__tests__/utils/*.test.ts',
],
integration: [
'packages/client-node/__tests__/integration/*.test.ts',
'packages/client-common/__tests__/integration/*.test.ts',
],
// TLS tests require a specific environment setup
// This list is integration + TLS tests
tls: [
'packages/client-node/__tests__/integration/*.test.ts',
'packages/client-common/__tests__/integration/*.test.ts',
'packages/client-node/__tests__/tls/*.test.ts',
],
common: [
'packages/client-common/__tests__/unit/*.test.ts',
'packages/client-common/__tests__/utils/*.test.ts',
],
'common-integration': [
'packages/client-common/__tests__/integration/*.test.ts',
],
all: [
'packages/client-common/__tests__/unit/*.test.ts',
'packages/client-common/__tests__/utils/*.test.ts',
'packages/client-common/__tests__/integration/*.test.ts',
'packages/client-node/__tests__/tls/*.test.ts',
'packages/client-node/__tests__/unit/*.test.ts',
'packages/client-node/__tests__/utils/*.test.ts',
'packages/client-node/__tests__/integration/*.test.ts',
],
}
export default defineConfig({
test: {
// Increase maxWorkers to speed up integration tests
// as we're not bound by the CPU here.
maxWorkers: '400%',
// Cover the Cloud instance wake-up time
hookTimeout: 300_000,
testTimeout: 300_000,
slowTestThreshold: testMode === 'unit' ? 10_000 : undefined,
setupFiles: ['vitest.node.setup.ts'],
include: collections[testMode],
coverage: {
enabled: process.env.VITEST_COVERAGE === 'true',
provider: 'istanbul',
reporter: ['lcov', 'text'],
include: [
'packages/client-common/src/**/*.ts',
'packages/client-node/src/**/*.ts',
],
exclude: [
'packages/**/version.ts',
'packages/client-common/src/clickhouse_types.ts',
'packages/client-common/src/connection.ts',
'packages/client-common/src/result.ts',
'packages/client-common/src/ts_utils.ts',
],
},
env: {
CLICKHOUSE_CLOUD_HOST: process.env.CLICKHOUSE_CLOUD_HOST,
CLICKHOUSE_CLOUD_PASSWORD: process.env.CLICKHOUSE_CLOUD_PASSWORD,
CLICKHOUSE_CLOUD_JWT_ACCESS_TOKEN:
process.env.CLICKHOUSE_CLOUD_JWT_ACCESS_TOKEN,
CLICKHOUSE_TEST_SKIP_INIT: process.env.CLICKHOUSE_TEST_SKIP_INIT,
CLICKHOUSE_TEST_ENVIRONMENT: process.env.CLICKHOUSE_TEST_ENVIRONMENT,
},
experimental: {
openTelemetry: {
enabled:
process.env.VITEST_OTEL_ENABLED === 'true' &&
// not set in dependabot PRs
!!process.env.OTEL_EXPORTER_OTLP_ENDPOINT,
sdkPath: './vitest.node.otel.js',
},
},
retry: process.env.CI ? 2 : 0,
},
resolve: {
alias: {
'@clickhouse/client-common': 'packages/client-common/src',
'@clickhouse/client-node': 'packages/client-node/src',
'@test': 'packages/client-common/__tests__',
},
},
})