From 997725c64e1df94e315d43eb84c38c1a1003c930 Mon Sep 17 00:00:00 2001 From: "detail-app[bot]" Date: Fri, 4 Sep 2026 02:58:45 +0000 Subject: [PATCH] test: restore setTimeout spy after use to prevent test leakage --- .../__test__/process/execAsync.test.ts | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/apps/dokploy/__test__/process/execAsync.test.ts b/apps/dokploy/__test__/process/execAsync.test.ts index ed70d657b..d115730ec 100644 --- a/apps/dokploy/__test__/process/execAsync.test.ts +++ b/apps/dokploy/__test__/process/execAsync.test.ts @@ -121,18 +121,22 @@ describe("execAsyncRemote", () => { mocks.findServerById.mockResolvedValue(makeServer()); const setTimeoutSpy = vi.spyOn(globalThis, "setTimeout"); - const promise = execAsyncRemote("s1", "echo hi"); - await flushMicrotasks(); + try { + const promise = execAsyncRemote("s1", "echo hi"); + await flushMicrotasks(); - const client = getLastClient(); - expect(client.connect).toHaveBeenCalledTimes(1); + const client = getLastClient(); + expect(client.connect).toHaveBeenCalledTimes(1); - expect(setTimeoutSpy.mock.calls.filter((call) => call[1] === 1000)).toEqual( - [], - ); + expect( + setTimeoutSpy.mock.calls.filter((call) => call[1] === 1000), + ).toEqual([]); - // Settle the pending connection so the test does not hang. - client.emit("error", new Error("aborted")); - await expect(promise).rejects.toThrow("SSH connection error: aborted"); + // Settle the pending connection so the test does not hang. + client.emit("error", new Error("aborted")); + await expect(promise).rejects.toThrow("SSH connection error: aborted"); + } finally { + setTimeoutSpy.mockRestore(); + } }); });