Skip to content

Commit ff87f63

Browse files
committed
fix(test): create separate vitest config for integration tests
The integration tests were failing because vitest.config.mts excludes test/integration/** directory, preventing test discovery even when files are explicitly specified. Fixed by: - Creating vitest.integration.config.mts specifically for integration tests - Removing test/integration/** from exclude patterns - Increasing testTimeout to 60s for longer-running integration tests - Adding cwd: ROOT_DIR to spawn options for correct working directory This allows integration tests to run independently without conflicting with the main test suite configuration.
1 parent 4b75e1e commit ff87f63

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

packages/cli/scripts/integration.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,10 @@ async function runVitest(binaryType) {
117117
'run',
118118
'test/integration/binary/binary-test-suite.test.mts',
119119
'--config',
120-
'vitest.config.mts',
120+
'vitest.integration.config.mts',
121121
],
122122
{
123+
cwd: ROOT_DIR,
123124
env: {
124125
...process.env,
125126
RUN_INTEGRATION_TESTS: '1', // Automatically enable tests when explicitly running integration.mjs.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import os from 'node:os'
2+
import path from 'node:path'
3+
import { fileURLToPath } from 'node:url'
4+
5+
import { defineConfig } from 'vitest/config'
6+
7+
import { getLocalPackageAliases } from './scripts/utils/get-local-package-aliases.mjs'
8+
9+
// Get the socket-cli repo root directory.
10+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
11+
const repoRoot = path.resolve(__dirname, '../..')
12+
13+
export default defineConfig({
14+
resolve: {
15+
alias: getLocalPackageAliases(repoRoot),
16+
preserveSymlinks: false,
17+
},
18+
test: {
19+
globals: false,
20+
environment: 'node',
21+
include: ['test/integration/**/*.test.{mts,ts}'],
22+
exclude: [
23+
'**/node_modules/**',
24+
'**/dist/**',
25+
'**/.{idea,git,cache,output,temp}/**',
26+
'**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*',
27+
],
28+
reporters: ['default'],
29+
setupFiles: ['./test/setup.mts'],
30+
pool: 'threads',
31+
poolOptions: {
32+
threads: {
33+
singleThread: false,
34+
maxThreads: os.cpus().length,
35+
minThreads: Math.min(2, Math.floor(os.cpus().length / 2)),
36+
isolate: true,
37+
},
38+
},
39+
testTimeout: 60_000, // Integration tests may take longer.
40+
hookTimeout: 30_000,
41+
fileParallelism: true,
42+
},
43+
})

0 commit comments

Comments
 (0)