(check: () => T | undefined, timeout = 1_000)
| 29 | } |
| 30 | |
| 31 | async function waitFor<T>(check: () => T | undefined, timeout = 1_000): Promise<T> { |
| 32 | const end = Date.now() + timeout |
| 33 | while (Date.now() < end) { |
| 34 | const value = check() |
| 35 | if (value !== undefined) { |
| 36 | return value |
| 37 | } |
| 38 | |
| 39 | await Bun.sleep(10) |
| 40 | } |
| 41 | |
| 42 | throw new Error("timed out waiting for value") |
| 43 | } |
| 44 | |
| 45 | function busy(sessionID = "session-1") { |
| 46 | return { |
no test coverage detected