test: tighten session cost polling · openclaw/openclaw@8f856c1
shakkernerd
·
2026-05-09
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -35,14 +35,10 @@ describe("session cost usage", () => {
|
35 | 35 | "", |
36 | 36 | ].join("\n"); |
37 | 37 | const waitFor = async (predicate: () => Promise<boolean>, timeoutMs = 2_000): Promise<void> => { |
38 | | -const deadline = Date.now() + timeoutMs; |
39 | | -while (Date.now() < deadline) { |
40 | | -if (await predicate()) { |
41 | | -return; |
42 | | -} |
43 | | -await new Promise((resolve) => setTimeout(resolve, 25)); |
44 | | -} |
45 | | -throw new Error("Timed out waiting for condition"); |
| 38 | +await vi.waitFor(async () => expect(await predicate()).toBe(true), { |
| 39 | +interval: 1, |
| 40 | +timeout: timeoutMs, |
| 41 | +}); |
46 | 42 | }; |
47 | 43 | const requireValue = <T>(value: T | null | undefined, message: string): T => { |
48 | 44 | if (value == null) { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。