(predicate: () => boolean, timeoutMs: number)
| 23 | return false |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | async function waitUntil(predicate: () => boolean, timeoutMs: number): Promise<boolean> { |
| 28 | const deadline = Date.now() + timeoutMs |
| 29 | while (Date.now() < deadline) { |
| 30 | if (predicate()) return true |
| 31 | await new Promise((resolve) => setTimeout(resolve, 50)) |
| 32 | } |
| 33 | return predicate() |
| 34 | } |
| 35 |
no test coverage detected