(read, predicate, description, timeout = 20000)
| 38 | const logs = (project, extra = '') => json(`/api/logs?lines=500&min_level=warn${project === undefined ? '' : `&project=${encodeURIComponent(project)}`}${extra}`); |
| 39 | |
| 40 | async function eventually(read, predicate, description, timeout = 20000) { |
| 41 | const deadline = Date.now() + timeout; |
| 42 | let last; |
| 43 | while (Date.now() < deadline) { |
| 44 | last = await read(); |
| 45 | if (predicate(last)) return last; |
| 46 | await delay(200); |
| 47 | } |
| 48 | throw new Error(`${description}: ${JSON.stringify(last)?.slice(0, 1200)}`); |
| 49 | } |
| 50 | |
| 51 | async function capture(page, file, locator) { |
| 52 | await page.bringToFront(); |
no test coverage detected