@syngrisi/syngrisi
Version:
Syngrisi - Visual Testing Tool
15 lines (13 loc) • 421 B
text/typescript
export const waitUntil = async (cb: () => Promise<boolean>, attempts: number = 5, interval: number = 700): Promise<boolean> => {
let result = false;
let iteration = 0;
while (result === false) {
result = await cb();
await new Promise((r) => setTimeout(r, interval));
iteration += 1;
if (iteration > attempts) {
result = true;
}
}
return result;
};