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:
@@ -121,7 +121,6 @@ describe("executeOnCompleteHook", () => {
|
|||||||
|
|
||||||
it("command failure logs warning but does not throw", async () => {
|
it("command failure logs warning but does not throw", async () => {
|
||||||
// given
|
// given
|
||||||
const consoleErrorSpy = spyOn(console, "error").mockImplementation(() => {})
|
|
||||||
const spawnSpy = spyOn(Bun, "spawn").mockReturnValue(createProc(1))
|
const spawnSpy = spyOn(Bun, "spawn").mockReturnValue(createProc(1))
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -144,13 +143,11 @@ describe("executeOnCompleteHook", () => {
|
|||||||
expect(warningCall).toBeDefined()
|
expect(warningCall).toBeDefined()
|
||||||
} finally {
|
} finally {
|
||||||
spawnSpy.mockRestore()
|
spawnSpy.mockRestore()
|
||||||
consoleErrorSpy.mockRestore()
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it("spawn error logs warning but does not throw", async () => {
|
it("spawn error logs warning but does not throw", async () => {
|
||||||
// given
|
// given
|
||||||
const consoleErrorSpy = spyOn(console, "error").mockImplementation(() => {})
|
|
||||||
const spawnError = new Error("Command not found")
|
const spawnError = new Error("Command not found")
|
||||||
const spawnSpy = spyOn(Bun, "spawn").mockImplementation(() => {
|
const spawnSpy = spyOn(Bun, "spawn").mockImplementation(() => {
|
||||||
throw spawnError
|
throw spawnError
|
||||||
@@ -177,7 +174,6 @@ describe("executeOnCompleteHook", () => {
|
|||||||
expect(errorCalls.length).toBeGreaterThan(0)
|
expect(errorCalls.length).toBeGreaterThan(0)
|
||||||
} finally {
|
} finally {
|
||||||
spawnSpy.mockRestore()
|
spawnSpy.mockRestore()
|
||||||
consoleErrorSpy.mockRestore()
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user