( records: readonly TelemetryRecord[], event: string, timeoutMs: number, )
| 45 | } |
| 46 | |
| 47 | async function waitForEvent( |
| 48 | records: readonly TelemetryRecord[], |
| 49 | event: string, |
| 50 | timeoutMs: number, |
| 51 | ): Promise<TelemetryRecord> { |
| 52 | const deadline = Date.now() + timeoutMs; |
| 53 | while (Date.now() < deadline) { |
| 54 | const found = records.find((r) => r.event === event); |
| 55 | if (found !== undefined) return found; |
| 56 | await new Promise((res) => { |
| 57 | setTimeout(res, 10); |
| 58 | }); |
| 59 | } |
| 60 | throw new Error(`event ${event} not observed; got ${JSON.stringify(records)}`); |
| 61 | } |
| 62 | |
| 63 | let tmpDir: string; |
| 64 | let lockPath: string; |
no test coverage detected