(url, timeout = 30000, interval = 1000)
| 36 | } |
| 37 | |
| 38 | function waitForServer(url, timeout = 30000, interval = 1000) { |
| 39 | return new Promise((resolve, reject) => { |
| 40 | const startTime = Date.now(); |
| 41 | const checkServer = () => { |
| 42 | http |
| 43 | .get(url, res => { |
| 44 | if (res.statusCode === 200) { |
| 45 | resolve(); |
| 46 | } else { |
| 47 | retryOrFail(); |
| 48 | } |
| 49 | }) |
| 50 | .on('error', retryOrFail); |
| 51 | }; |
| 52 | |
| 53 | const retryOrFail = () => { |
| 54 | if (Date.now() - startTime < timeout) { |
| 55 | setTimeout(checkServer, interval); |
| 56 | } else { |
| 57 | reject(new Error('Server did not start in time')); |
| 58 | } |
| 59 | }; |
| 60 | |
| 61 | checkServer(); |
| 62 | }); |
| 63 | } |
| 64 | |
| 65 | async function getPageLinks() { |
| 66 | const packagePaths = [ |
no test coverage detected