import assert from "node:assert/strict"; import { describe, it } from "node:test"; import { getApiMock } from "./getApiMock"; import { getSwaggerData } from "./getSwaggerData"; describe("getSwaggerData", () => { it("stops MSW server after schema generation", async () => { const endpoint = "/utils-msw-close-check"; const url = "http://localhost"; const handler = getApiMock({ endpoint, mock: { ok: true }, }, url); const schema = await getSwaggerData({ handlers: [ handler ], meta: { title: "Test API", version: "1.0.0", }, queries: [], }); assert.strictEqual(schema.openapi, "3.1.0"); await assert.rejects( async () => fetch(`${url}${endpoint}`), /fetch failed|ECONNREFUSED|Failed to fetch|connect/i ); }); });