diff --git a/src/cli/gateway-cli/run-loop.test.ts b/src/cli/gateway-cli/run-loop.test.ts index a364f1547b4..de20676a449 100644 --- a/src/cli/gateway-cli/run-loop.test.ts +++ b/src/cli/gateway-cli/run-loop.test.ts @@ -627,9 +627,13 @@ describe("runGatewayLoop", () => { await withIsolatedSignals(async ({ captureSignal }) => { const { runtime, exited } = await createSignaledLoopHarness(); const sigusr1 = captureSignal("SIGUSR1"); - const startedAt = Date.now(); + vi.useFakeTimers(); sigusr1(); + await vi.advanceTimersByTimeAsync(1499); + expect(runtime.exit).not.toHaveBeenCalled(); + await vi.advanceTimersByTimeAsync(1); + await expect(exited).resolves.toBe(0); expect(runtime.exit).toHaveBeenCalledWith(0); expect(writeGatewayRestartHandoffSync).toHaveBeenCalledWith({ @@ -638,9 +642,9 @@ describe("runGatewayLoop", () => { processInstanceId: expect.any(String), supervisorMode: "launchd", }); - expect(Date.now() - startedAt).toBeGreaterThanOrEqual(1400); }); } finally { + vi.useRealTimers(); delete process.env.LAUNCH_JOB_LABEL; if (originalPlatformDescriptor) { Object.defineProperty(process, "platform", originalPlatformDescriptor);