( predicate: () => boolean, timeoutMs = 200, )
| 114 | } |
| 115 | |
| 116 | async function waitUntil( |
| 117 | predicate: () => boolean, |
| 118 | timeoutMs = 200, |
| 119 | ): Promise<void> { |
| 120 | const started = Date.now() |
| 121 | while (!predicate()) { |
| 122 | if (Date.now() - started > timeoutMs) { |
| 123 | throw new Error('Timed out waiting for condition') |
| 124 | } |
| 125 | await Bun.sleep(1) |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | beforeEach(async () => { |
| 130 | resetAnalytics() |
no test coverage detected