diff --git a/tests/presentation/cli/commands/decisions/show/decision.show.test.ts b/tests/presentation/cli/commands/decisions/show/decision.show.test.ts index b6d724f6..81121d4e 100644 --- a/tests/presentation/cli/commands/decisions/show/decision.show.test.ts +++ b/tests/presentation/cli/commands/decisions/show/decision.show.test.ts @@ -77,13 +77,29 @@ describe("decision.show command", () => { }); it("defaults non-TTY output to JSON when no format is supplied", async () => { - Renderer.reset(); - handle.mockResolvedValue({ decision }); - - await decisionShow({ id: "dec_123" }, container as IApplicationContainer); - - expect(stdout).toHaveBeenCalledTimes(1); - expect(JSON.parse(String(stdout.mock.calls[0][0]))).toEqual(decision); + const isTtyDescriptor = Object.getOwnPropertyDescriptor(process.stdout, "isTTY"); + Object.defineProperty(process.stdout, "isTTY", { + configurable: true, + value: false, + }); + + try { + Renderer.reset(); + handle.mockResolvedValue({ decision }); + + await decisionShow({ id: "dec_123" }, container as IApplicationContainer); + + expect(stdout).toHaveBeenCalledTimes(1); + expect(JSON.parse(String(stdout.mock.calls[0][0]))).toEqual(decision); + } finally { + Renderer.reset(); + + if (isTtyDescriptor) { + Object.defineProperty(process.stdout, "isTTY", isTtyDescriptor); + } else { + Reflect.deleteProperty(process.stdout, "isTTY"); + } + } }); it("reports unknown IDs only on stderr and sets a non-zero exit code", async () => { diff --git a/tests/presentation/cli/commands/project/init/project.init.test.ts b/tests/presentation/cli/commands/project/init/project.init.test.ts index 36f1532d..5fd22c38 100644 --- a/tests/presentation/cli/commands/project/init/project.init.test.ts +++ b/tests/presentation/cli/commands/project/init/project.init.test.ts @@ -191,6 +191,8 @@ describe("project.init command", () => { if (isTtyDescriptor) { Object.defineProperty(process.stdout, "isTTY", isTtyDescriptor); + } else { + Reflect.deleteProperty(process.stdout, "isTTY"); } });