forked from NangoHQ/nango
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.integration.config.ts
More file actions
99 lines (92 loc) · 4.09 KB
/
Copy pathvite.integration.config.ts
File metadata and controls
99 lines (92 loc) · 4.09 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
/// <reference types="vitest" />
// Configure Vitest (https://vitest.dev/config/)
import fs from 'node:fs';
import path from 'node:path';
import { defaultExclude, defineConfig } from 'vitest/config';
process.env.TZ = 'UTC';
// Tests that cannot share a process with the rest of the suite.
//
// `vi.mock` only intercepts a module that has not been imported yet, and with a shared registry
// the server graph is already loaded by the time these files register their mocks, so the real
// module wins. Discovered by scanning rather than listed by hand: a hardcoded list silently
// breaks whenever someone adds a `vi.mock` suite, and the failure looks like an unrelated bug
// (the real client runs, so you get a 500 rather than a mocking error).
function findSuitesUsingViMock(root: string): string[] {
const found: string[] = [];
const walk = (dir: string) => {
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
if (entry.name === 'node_modules' || entry.name === 'dist' || entry.name.startsWith('.')) {
continue;
}
const full = path.join(dir, entry.name);
if (entry.isDirectory()) {
walk(full);
} else if (entry.name.endsWith('.integration.test.ts') && fs.readFileSync(full, 'utf8').includes('vi.mock(')) {
found.push(full);
}
}
};
walk(root);
return found;
}
const needsOwnProcess = findSuitesUsingViMock('packages');
const shared = {
include: ['**/*.integration.{test,spec}.?(c|m)[jt]s?(x)'],
// Vitest 4 dropped dist/** from its defaultExclude, so compiled test files
// built into packages/*/dist get collected and run as duplicates. Re-add it.
exclude: [...defaultExclude, '**/dist/**'],
setupFiles: './tests/setupFiles.ts',
testTimeout: 20000,
hookTimeout: 20000,
env: {
NANGO_ENCRYPTION_KEY: 'RzV4ZGo5RlFKMm0wYWlXdDhxTFhwb3ZrUG5KNGg3TmU=',
NANGO_LOGS_ENABLED: 'true',
NANGO_LOGS_ES_PREFIX: 'test',
FLAG_PLAN_ENABLED: 'true',
ORCHESTRATOR_SERVICE_URL: 'http://orchestrator',
RUNNER_NODE_ID: '1',
FLAG_API_RATE_LIMIT_ENABLED: 'false',
FLAG_AUTH_ROLES_ENABLED: 'true',
NANGO_MANAGEMENT_MCP_SERVER_URL: 'https://mcp-test.nango.dev',
// Used by allProxy.integration.test.ts denylist case; must be set before server modules load
NANGO_PROXY_BASE_URL_OVERRIDE_DENYLIST: JSON.stringify(['denylisted-proxy-test.invalid']),
// Opens the per-request `source=clickhouse` override gate so
// getBillingUsage.integration.test.ts can exercise the CH path.
// No effect on default behavior — every other request without the
// explicit override still resolves to Orb.
FLAG_ALLOW_OVERRIDE_GETUSAGE_SERVICE: 'true'
},
fileParallelism: false,
pool: 'forks' as const,
// Vitest 4 removed test.poolOptions; poolOptions.forks.singleFork is now maxWorkers: 1.
maxWorkers: 1
};
export default defineConfig({
test: {
// Same suite, split into two filesets that differ only in `isolate`. globalSetup stays
// at the root so one set of containers is started for the run and shared by both,
// rather than each fileset spinning up its own Postgres and Elasticsearch.
globalSetup: './tests/setup.ts',
projects: [
{
test: {
...shared,
name: 'integration',
exclude: [...shared.exclude, ...needsOwnProcess],
// Safe to share a process: these are already serial and already share
// Postgres and Elasticsearch, so a fresh process per file adds no isolation
// it does not already have, and re-imports the whole @nangohq graph each time.
isolate: false
}
},
{
test: {
...shared,
name: 'integration-isolated',
include: needsOwnProcess,
isolate: true
}
}
]
}
});