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.
This commit is contained in:
YeonGyu-Kim
2026-02-07 17:54:56 +09:00
parent eafcac1593
commit 266c045b69

View File

@@ -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()
}
})
})