(href: RequestInfo)
| 37 | }; |
| 38 | |
| 39 | const waitForDeployment = async (href: RequestInfo) => { |
| 40 | console.log(`waiting for ${href} to become ready...`); |
| 41 | const start = Date.now(); |
| 42 | const max = ms('4m'); |
| 43 | |
| 44 | while (true) { |
| 45 | const response = await nodeFetch(href, { redirect: 'manual' }); |
| 46 | const text = await response.text(); |
| 47 | if ( |
| 48 | response.status === 200 && |
| 49 | !text.includes('<title>Deployment Overview') |
| 50 | ) { |
| 51 | break; |
| 52 | } |
| 53 | |
| 54 | const current = Date.now(); |
| 55 | |
| 56 | if (current - start > max || response.status >= 500) { |
| 57 | throw new Error( |
| 58 | `Waiting for "${href}" failed since it took longer than 4 minutes.\n` + |
| 59 | `Received status ${response.status}:\n"${text}"` |
| 60 | ); |
| 61 | } |
| 62 | |
| 63 | await sleep(2000); |
| 64 | } |
| 65 | }; |
| 66 | |
| 67 | beforeAll(async () => { |
| 68 | try { |
no test coverage detected