| 292 | }) |
| 293 | |
| 294 | async function readTraceZip(zipPath: string): Promise<{ entries: string[]; events: any[] }> { |
| 295 | const zipFile = new ZipFile(zipPath) |
| 296 | try { |
| 297 | const entries = await zipFile.entries() |
| 298 | const traceText = (await zipFile.read('trace.trace')).toString('utf-8') |
| 299 | const events = traceText |
| 300 | .split('\n') |
| 301 | .filter(Boolean) |
| 302 | .map((line) => { |
| 303 | return JSON.parse(line) |
| 304 | }) |
| 305 | return { entries, events } |
| 306 | } |
| 307 | finally { |
| 308 | zipFile.close() |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | // https://github.com/microsoft/playwright/blob/cd36dab6ecc7f4b3adeec333e55f9ac03711a9b1/packages/playwright-core/src/server/utils/zipFile.ts#L21 |
| 313 | class ZipFile { |