mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-14 00:46:38 +00:00
perf(test): use expect.poll in browserless live test
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { describe, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
import { isTruthyEnvValue } from "../infra/env.js";
|
import { isTruthyEnvValue } from "../infra/env.js";
|
||||||
|
|
||||||
const LIVE = isTruthyEnvValue(process.env.LIVE) || isTruthyEnvValue(process.env.OPENCLAW_LIVE_TEST);
|
const LIVE = isTruthyEnvValue(process.env.LIVE) || isTruthyEnvValue(process.env.OPENCLAW_LIVE_TEST);
|
||||||
@@ -9,14 +9,7 @@ async function waitFor(
|
|||||||
fn: () => Promise<boolean>,
|
fn: () => Promise<boolean>,
|
||||||
opts: { timeoutMs: number; intervalMs: number },
|
opts: { timeoutMs: number; intervalMs: number },
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const deadline = Date.now() + opts.timeoutMs;
|
await expect.poll(fn, { timeout: opts.timeoutMs, interval: opts.intervalMs }).toBe(true);
|
||||||
while (Date.now() < deadline) {
|
|
||||||
if (await fn()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await new Promise((r) => setTimeout(r, opts.intervalMs));
|
|
||||||
}
|
|
||||||
throw new Error("timed out");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
describeLive("browser (live): remote CDP tab persistence", () => {
|
describeLive("browser (live): remote CDP tab persistence", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user