(cond: () => boolean, timeoutMs = 2000)
| 158 | } |
| 159 | |
| 160 | async function waitFor(cond: () => boolean, timeoutMs = 2000): Promise<void> { |
| 161 | const deadline = Date.now() + timeoutMs; |
| 162 | while (Date.now() < deadline) { |
| 163 | if (cond()) return; |
| 164 | await new Promise((r) => setTimeout(r, 10)); |
| 165 | } |
| 166 | throw new Error(`waitFor: condition not satisfied within ${timeoutMs}ms`); |
| 167 | } |
| 168 | |
| 169 | describe('WS durable journal + resync_required (v2)', () => { |
| 170 | it('reconnect with a cursor replays buffered events in order', async () => { |
no test coverage detected