perf(test): eliminate resetModules via injectable seams

This commit is contained in:
Peter Steinberger
2026-02-13 16:20:31 +00:00
parent a844fb161c
commit b272158fe4
21 changed files with 223 additions and 188 deletions

View File

@@ -1,14 +1,15 @@
import { afterEach, expect, test, vi } from "vitest";
import { resetProcessRegistryForTests } from "./bash-process-registry";
import { createExecTool, setPtyModuleLoaderForTests } from "./bash-tools.exec";
afterEach(() => {
resetProcessRegistryForTests();
vi.resetModules();
setPtyModuleLoaderForTests();
vi.clearAllMocks();
});
test("exec falls back when PTY spawn fails", async () => {
vi.doMock("@lydell/node-pty", () => ({
setPtyModuleLoaderForTests(async () => ({
spawn: () => {
const err = new Error("spawn EBADF");
(err as NodeJS.ErrnoException).code = "EBADF";
@@ -16,7 +17,6 @@ test("exec falls back when PTY spawn fails", async () => {
},
}));
const { createExecTool } = await import("./bash-tools.exec");
const tool = createExecTool({ allowBackground: false });
const result = await tool.execute("toolcall", {
command: "printf ok",