Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

chore(test): update test setup to use modern Vitest configuration

Steven Enamakele2b7a20a852d
diff --git a/app/src/test/setup.ts b/app/src/test/setup.ts
index 1b642b7381..b7f703930c 100644
--- a/app/src/test/setup.ts
+++ b/app/src/test/setup.ts
@@ -36,8 +36,13 @@ const DEFAULT_TEST_MOCK_API_PORT = 5005;
function readMockApiPort() {
const rawPort = process.env.VITEST_MOCK_API_PORT ?? process.env.MOCK_API_PORT;
- const port = rawPort ? Number(rawPort) : DEFAULT_TEST_MOCK_API_PORT;
- return Number.isInteger(port) && port > 0 ? port : DEFAULT_TEST_MOCK_API_PORT;
+ const base = rawPort ? Number(rawPort) : DEFAULT_TEST_MOCK_API_PORT;
+ const port = Number.isInteger(base) && base > 0 ? base : DEFAULT_TEST_MOCK_API_PORT;
+ // One port per vitest worker (VITEST_POOL_ID is 1..maxWorkers). Every test
+ // file starts its own server, so parallel workers sharing one preferred
+ // port sent all but one of them through the EADDRINUSE retry loop.
+ const poolId = Number(process.env.VITEST_POOL_ID);
+ return Number.isInteger(poolId) && poolId > 1 ? port + poolId - 1 : port;
}
const mockApiServer = await startMockServer(readMockApiPort(), { retryIfInUse: true });