diff --git a/tests/integration/server.test.ts b/tests/integration/server.test.ts index 7b9d1b46..1d804943 100644 --- a/tests/integration/server.test.ts +++ b/tests/integration/server.test.ts @@ -1,18 +1,16 @@ import { Client } from "@modelcontextprotocol/sdk/client/index.js"; -import { Server } from "../../src/server.js"; import { setupIntegrationTest } from "./helpers.js"; describe("Server integration test", () => { let client: Client; - let server: Server; + let teardown: () => Promise; beforeEach(async () => { - ({ client, server } = await setupIntegrationTest()); + ({ client, teardown } = await setupIntegrationTest()); }); afterEach(async () => { - await client?.close(); - await server?.close(); + await teardown(); }); describe("list capabilities", () => { diff --git a/tests/integration/tools/mongodb/connect.test.ts b/tests/integration/tools/mongodb/connect.test.ts index d304c266..7e5dacec 100644 --- a/tests/integration/tools/mongodb/connect.test.ts +++ b/tests/integration/tools/mongodb/connect.test.ts @@ -14,6 +14,10 @@ describe("Connect tool", () => { cluster = await runMongoDB(); }, 60_000); + beforeEach(async () => { + ({ client, teardown: serverClientTeardown } = await setupIntegrationTest()); + }); + afterEach(async () => { await serverClientTeardown?.(); }); @@ -23,10 +27,6 @@ describe("Connect tool", () => { }); describe("with default config", () => { - beforeEach(async () => { - ({ client, teardown: serverClientTeardown } = await setupIntegrationTest()); - }); - it("should have correct metadata", async () => { const tools = await client.listTools(); const connectTool = tools.tools.find((tool) => tool.name === "connect"); @@ -84,8 +84,6 @@ describe("Connect tool", () => { describe("with connection string in config", () => { beforeEach(async () => { config.connectionString = cluster.connectionString; - - ({ client, teardown: serverClientTeardown } = await setupIntegrationTest()); }); it("uses the connection string from config", async () => {