diff --git a/.changeset/fix-jest-open-handles.md b/.changeset/fix-jest-open-handles.md new file mode 100644 index 000000000..ed48bbd81 --- /dev/null +++ b/.changeset/fix-jest-open-handles.md @@ -0,0 +1,5 @@ +--- +"counterfact": patch +--- + +Fix Jest worker process failing to exit gracefully by closing REPL servers after each test in the repl test suite. diff --git a/test/repl/repl.test.ts b/test/repl/repl.test.ts index bebc0beb9..18887c1ad 100644 --- a/test/repl/repl.test.ts +++ b/test/repl/repl.test.ts @@ -1,6 +1,6 @@ import type { REPLServer } from "node:repl"; -import { jest } from "@jest/globals"; +import { afterEach, jest } from "@jest/globals"; import { createCompleter, startRepl } from "../../src/repl/repl.js"; import type { CompleterCallback } from "../../src/repl/repl.js"; @@ -101,9 +101,21 @@ function createHarness(scenarioRegistry?: ScenarioRegistry) { scenarioRegistry, ); + openServers.push(harness.server); + return { config, contextRegistry, harness, registry }; } +const openServers: REPLServer[] = []; + +afterEach(() => { + for (const server of openServers) { + server.close(); + } + + openServers.length = 0; +}); + describe("REPL", () => { it("turns on the proxy globally", () => { const { config, harness } = createHarness();