From 5d0b3d0469d2fa2e7664dd23453f37bfecfd0a3c Mon Sep 17 00:00:00 2001 From: Benjamin Ratiarisolo Date: Thu, 14 Aug 2025 16:46:33 +0200 Subject: [PATCH] Use port from returned HTTP server in test --- tests/http-transport.test.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/http-transport.test.ts b/tests/http-transport.test.ts index 650172e..88471f5 100644 --- a/tests/http-transport.test.ts +++ b/tests/http-transport.test.ts @@ -6,11 +6,9 @@ import { DecisionRuntime } from "../src/decision-runtime.js"; import { createMcpServer } from "../src/mcp-server.js"; import { Server } from "http"; import { TEST_CONFIG, TEST_INPUT, TEST_EXPECTATIONS, setupNockMocks, validateToolListing, validateToolExecution } from "./test-utils.js"; +import { AddressInfo } from 'net'; describe('HTTP Transport', () => { - const port = 3000; // Use the default port from runHTTPServer - const httpServerUrl = `http://localhost:${port}/mcp`; - beforeAll(() => { setupNockMocks(); }); @@ -47,7 +45,8 @@ describe('HTTP Transport', () => { ); // Connect client to server via HTTP - clientTransport = new StreamableHTTPClientTransport(new URL(httpServerUrl)); + const address = httpServer.address() as AddressInfo; + clientTransport = new StreamableHTTPClientTransport(new URL(`http://localhost:${address.port}/mcp`)); await client.connect(clientTransport);