* Wait for Postgres to be ready
(client: Client)
| 73 | * Wait for Postgres to be ready |
| 74 | */ |
| 75 | async function waitForPostgres(client: Client): Promise<void> { |
| 76 | return new Promise<void>((resolve, reject) => { |
| 77 | const timeout = setTimeout(() => { |
| 78 | reject(new Error('Timed out waiting for Postgres')) |
| 79 | }, 10000) |
| 80 | |
| 81 | const check = async (): Promise<void> => { |
| 82 | try { |
| 83 | await client.connect() |
| 84 | clearTimeout(timeout) |
| 85 | return resolve() |
| 86 | } catch { |
| 87 | setTimeout(() => void check(), 100) |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | void check() |
| 92 | }) |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Global setup for e2e test suite |