( predicate: () => boolean | Promise<boolean>, timeoutMs = 5000, intervalMs = 20, )
| 8 | import type { OfflineConfig, StorageDiagnostic } from '../src/types' |
| 9 | |
| 10 | const waitUntil = async ( |
| 11 | predicate: () => boolean | Promise<boolean>, |
| 12 | timeoutMs = 5000, |
| 13 | intervalMs = 20, |
| 14 | ) => { |
| 15 | const deadline = Date.now() + timeoutMs |
| 16 | while (Date.now() < deadline) { |
| 17 | if (await predicate()) { |
| 18 | return |
| 19 | } |
| 20 | await new Promise((resolve) => setTimeout(resolve, intervalMs)) |
| 21 | } |
| 22 | throw new Error(`Timed out waiting for condition`) |
| 23 | } |
| 24 | |
| 25 | describe(`storage failure handling`, () => { |
| 26 | let mockCollection: any |
no outgoing calls
no test coverage detected