(artifacts, { indent = ' ', consoleCount } = {})
| 42 | } |
| 43 | |
| 44 | export function artifactLinks(artifacts, { indent = ' ', consoleCount } = {}) { |
| 45 | const lines = [] |
| 46 | const order = ['html', 'aria', 'screenshot', 'console', 'storage'] |
| 47 | |
| 48 | for (const key of order) { |
| 49 | const file = artifacts[key] |
| 50 | if (!file) continue |
| 51 | const label = ARTIFACT_LABELS[key] |
| 52 | let line = `${indent}> [${label}](./${file})` |
| 53 | if (key === 'console') { |
| 54 | const count = consoleCount ?? artifacts.consoleCount ?? 0 |
| 55 | line += ` (${count} entries)` |
| 56 | } else if (key === 'storage') { |
| 57 | const cookies = artifacts.cookieCount ?? 0 |
| 58 | const ls = artifacts.localStorageCount ?? 0 |
| 59 | line += ` (${cookies} cookies, ${ls} localStorage)` |
| 60 | } |
| 61 | lines.push(line) |
| 62 | } |
| 63 | |
| 64 | return lines.join('\n') |
| 65 | } |
| 66 | |
| 67 | export function fileToUrl(dir, basename) { |
| 68 | return pathToFileURL(path.join(dir, basename)).href |
no test coverage detected