Skip to content

Commit 5b4a36a

Browse files
committed
test: fix integration test timeouts by replacing inline tsx -e with proxy-runner script
Tests 1-2 were timing out because npx had to download tsx on cold start (not in devDeps), blowing the 5s waitForResponses timeout before the subprocess was ready. Also replaces fragile ESM import inside -e inline code with a proper file entrypoint.
1 parent eceb308 commit 5b4a36a

2 files changed

Lines changed: 15 additions & 10 deletions

File tree

test/integration.test.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,21 @@ import { createInterface } from "node:readline";
77
import type { LogEntry } from "../src/logger.js";
88

99
const MOCK_SERVER = join(import.meta.dirname, "mock-mcp-server.ts");
10-
const PROXY_MODULE = join(import.meta.dirname, "..", "src", "proxy.ts");
10+
const PROXY_RUNNER = join(import.meta.dirname, "proxy-runner.ts");
1111

1212
/**
1313
* Spawns a proxy process that wraps the mock MCP server,
1414
* sends JSON-RPC messages, and collects responses.
1515
*/
1616
function createTestProxy(logDir: string) {
17-
const child = spawn("npx", ["tsx", "-e", `
18-
import { startProxy } from "${PROXY_MODULE.replace(/\\/g, "/")}";
19-
process.env.FLIGHT_LOG_DIR = "${logDir.replace(/\\/g, "/")}";
20-
startProxy({
21-
command: "npx",
22-
args: ["tsx", "${MOCK_SERVER.replace(/\\/g, "/")}"],
23-
logDir: "${logDir.replace(/\\/g, "/")}",
24-
});
25-
`], {
17+
const child = spawn("npx", ["tsx", PROXY_RUNNER], {
2618
stdio: ["pipe", "pipe", "pipe"],
19+
env: {
20+
...process.env,
21+
UPSTREAM_COMMAND: "npx",
22+
UPSTREAM_ARGS: JSON.stringify(["tsx", MOCK_SERVER]),
23+
LOG_DIR: logDir,
24+
},
2725
});
2826

2927
const responses: Array<Record<string, unknown>> = [];

test/proxy-runner.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { startProxy } from "../src/proxy.js";
2+
3+
await startProxy({
4+
command: process.env.UPSTREAM_COMMAND!,
5+
args: JSON.parse(process.env.UPSTREAM_ARGS!),
6+
logDir: process.env.LOG_DIR,
7+
});

0 commit comments

Comments
 (0)