test(infra): avoid max fake-timer jumps (#88155) · openclaw/openclaw@73dd366
RomneyDa
·
2026-05-30
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -55,7 +55,7 @@ describe("Feishu app registration", () => {
|
55 | 55 | |
56 | 56 | expect(setTimeoutSpy).toHaveBeenCalledWith(expect.any(Function), MAX_TIMER_TIMEOUT_MS); |
57 | 57 | |
58 | | -await vi.advanceTimersByTimeAsync(MAX_TIMER_TIMEOUT_MS); |
| 58 | +await vi.runOnlyPendingTimersAsync(); |
59 | 59 | await expect(poll).resolves.toEqual({ status: "timeout" }); |
60 | 60 | }); |
61 | 61 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -109,6 +109,7 @@ describe("waitForTransportReady", () => {
|
109 | 109 | |
110 | 110 | it("caps oversized timeout values before computing the deadline", async () => { |
111 | 111 | vi.setSystemTime(1_000); |
| 112 | +const setTimeoutSpy = vi.spyOn(globalThis, "setTimeout"); |
112 | 113 | const runtime = createRuntime(); |
113 | 114 | const waitPromise = waitForTransportReady({ |
114 | 115 | label: "test transport", |
@@ -122,8 +123,9 @@ describe("waitForTransportReady", () => {
|
122 | 123 | |
123 | 124 | await vi.advanceTimersByTimeAsync(1); |
124 | 125 | expect(runtime.error).not.toHaveBeenCalled(); |
| 126 | +expect(setTimeoutSpy).toHaveBeenCalledWith(expect.any(Function), MAX_TIMER_TIMEOUT_MS); |
125 | 127 | |
126 | | -await vi.advanceTimersByTimeAsync(MAX_TIMER_TIMEOUT_MS - 1); |
| 128 | +await vi.runOnlyPendingTimersAsync(); |
127 | 129 | await asserted; |
128 | 130 | expect(latestRuntimeErrorMessage(runtime)).toContain( |
129 | 131 | `not ready after ${MAX_TIMER_TIMEOUT_MS}ms`, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。