waitFor

tcmts.cli.test.e2e.prod.waitFor · #q4dxnqg4 · term · runs anywhere

export const waitFor = async (cond: () => boolean | Promise<boolean>, ms = 20000) => {
  for (const end = Date.now() + ms; Date.now() < end; await new Promise((r) => setTimeout(r, 150))) if (await cond()) return;
  throw new Error("timed out waiting");
}

used by