From 266c045b6966f5252e8f3b0b6eb8a0de82b39fba Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Sat, 7 Feb 2026 17:54:56 +0900 Subject: [PATCH] fix(test): remove shadowed consoleErrorSpy declarations in on-complete-hook tests Remove duplicate consoleErrorSpy declarations in 'command failure' and 'spawn error' tests that shadowed the outer beforeEach/afterEach-managed spy. The inner declarations created a second spy on the already-spied console.error, causing restore confusion and potential test leakage. --- src/cli/run/on-complete-hook.test.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/cli/run/on-complete-hook.test.ts b/src/cli/run/on-complete-hook.test.ts index e050473dc..e560cc10c 100644 --- a/src/cli/run/on-complete-hook.test.ts +++ b/src/cli/run/on-complete-hook.test.ts @@ -121,7 +121,6 @@ describe("executeOnCompleteHook", () => { it("command failure logs warning but does not throw", async () => { // given - const consoleErrorSpy = spyOn(console, "error").mockImplementation(() => {}) const spawnSpy = spyOn(Bun, "spawn").mockReturnValue(createProc(1)) try { @@ -144,13 +143,11 @@ describe("executeOnCompleteHook", () => { expect(warningCall).toBeDefined() } finally { spawnSpy.mockRestore() - consoleErrorSpy.mockRestore() } }) it("spawn error logs warning but does not throw", async () => { // given - const consoleErrorSpy = spyOn(console, "error").mockImplementation(() => {}) const spawnError = new Error("Command not found") const spawnSpy = spyOn(Bun, "spawn").mockImplementation(() => { throw spawnError @@ -177,7 +174,6 @@ describe("executeOnCompleteHook", () => { expect(errorCalls.length).toBeGreaterThan(0) } finally { spawnSpy.mockRestore() - consoleErrorSpy.mockRestore() } }) })