@testrelic/playwright-analytics 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/reporter.ts","../src/config.ts","../src/schema.ts","../src/code-extractor.ts","../src/redaction.ts","../src/ci-detector.ts","../src/html-report.ts","../src/html-template.ts","../src/browser-open.ts","../src/index.ts"],"sourcesContent":["/**\n * TestRelicReporter — Playwright custom reporter\n *\n * Captures test execution data and produces a structured JSON timeline.\n * All hooks are wrapped in try/catch (FR-026): never crashes the test run.\n */\n\nimport { randomUUID } from 'node:crypto';\nimport { mkdirSync, writeFileSync, renameSync } from 'node:fs';\nimport { dirname, relative } from 'node:path';\nimport type {\n ReporterConfig,\n TestRunReport,\n Summary,\n TimelineEntry,\n TestResult as TRTestResult,\n NavigationAnnotation,\n FailureDiagnostic,\n TestStatus,\n} from '@testrelic/core';\nimport { resolveConfig } from './config.js';\nimport type { ResolvedConfig } from './config.js';\nimport { SCHEMA_VERSION } from './schema.js';\nimport { extractCodeSnippet } from './code-extractor.js';\nimport { createRedactor } from './redaction.js';\nimport { detectCI } from './ci-detector.js';\nimport { writeHtmlReport } from './html-report.js';\n\n// Playwright types — imported for type annotations only\ninterface PwFullConfig {\n rootDir: string;\n [key: string]: unknown;\n}\n\ninterface PwSuite {\n allTests(): PwTestCase[];\n}\n\ninterface PwTestCase {\n title: string;\n titlePath(): string[];\n annotations: Array<{ type: string; description?: string }>;\n tags?: string[];\n location: { file: string; line: number; column: number };\n results: PwTestResult[];\n outcome(): 'expected' | 'unexpected' | 'skipped' | 'flaky';\n id: string;\n}\n\ninterface PwTestResult {\n status: 'passed' | 'failed' | 'timedOut' | 'skipped' | 'interrupted';\n duration: number;\n startTime: Date;\n retry: number;\n errors: PwTestError[];\n}\n\ninterface PwTestError {\n message?: string;\n stack?: string;\n location?: { file: string; line: number; column: number };\n snippet?: string;\n}\n\ninterface PwFullResult {\n status: 'passed' | 'failed' | 'timedout' | 'interrupted';\n startTime: Date;\n duration: number;\n}\n\n// Internal state for collected test data\ninterface CollectedTest {\n titlePath: string[];\n title: string;\n status: TestStatus;\n duration: number;\n startedAt: string;\n completedAt: string;\n retryCount: number;\n tags: string[];\n failure: FailureDiagnostic | null;\n specFile: string;\n navigations: NavigationAnnotation[];\n}\n\nexport default class TestRelicReporter {\n private config: ResolvedConfig;\n private rootDir = '';\n private startedAt = '';\n private testRunId = '';\n private collectedTests: CollectedTest[] = [];\n\n constructor(options?: Partial<ReporterConfig>) {\n this.config = resolveConfig(options);\n }\n\n onBegin(config: PwFullConfig, _suite: PwSuite): void {\n try {\n this.rootDir = config.rootDir;\n this.startedAt = new Date().toISOString();\n this.testRunId = this.config.testRunId ?? randomUUID();\n } catch {\n // FR-026: never crash the test run\n }\n }\n\n onTestEnd(test: PwTestCase, result: PwTestResult): void {\n try {\n const lastResult = result;\n const outcome = test.outcome();\n\n let status: TestStatus;\n if (outcome === 'flaky') {\n status = 'flaky';\n } else if (lastResult.status === 'passed') {\n status = 'passed';\n } else {\n status = 'failed';\n }\n\n // Skip truly skipped tests\n if (outcome === 'skipped') return;\n\n const startedAt = lastResult.startTime.toISOString();\n const completedAt = new Date(lastResult.startTime.getTime() + lastResult.duration).toISOString();\n\n // Extract tags: prefer test.tags (1.42+), fallback to annotations\n const tags = test.tags\n ? [...test.tags]\n : test.annotations\n .filter((a) => a.type === 'tag')\n .map((a) => a.description ?? '');\n\n // Extract navigation annotations\n const navigations = test.annotations\n .filter((a) => a.type === 'lambdatest-navigation' && a.description)\n .map((a) => {\n try {\n return JSON.parse(a.description!) as NavigationAnnotation;\n } catch {\n return null;\n }\n })\n .filter((n): n is NavigationAnnotation => n !== null);\n\n // Build failure diagnostic\n let failure: FailureDiagnostic | null = null;\n if (status === 'failed' || status === 'flaky') {\n const errors = status === 'flaky'\n ? (test.results.find((r) => r.status !== 'passed')?.errors ?? [])\n : lastResult.errors;\n const firstError = errors[0];\n if (firstError) {\n const redact = createRedactor(this.config.redactPatterns);\n const errorLine = firstError.location?.line ?? null;\n let codeSnippet: string | null = null;\n if (this.config.includeCodeSnippets && errorLine !== null && firstError.location?.file) {\n codeSnippet = extractCodeSnippet(\n firstError.location.file,\n errorLine,\n this.config.codeContextLines,\n );\n if (codeSnippet) codeSnippet = redact(codeSnippet);\n }\n\n failure = {\n message: redact(firstError.message ?? 'Unknown error'),\n line: errorLine,\n code: codeSnippet,\n stack: this.config.includeStackTrace ? (firstError.stack ? redact(firstError.stack) : null) : null,\n };\n }\n }\n\n const titlePath = test.titlePath().filter(Boolean);\n const specFile = relative(this.rootDir || '.', test.location.file);\n\n this.collectedTests.push({\n titlePath,\n title: titlePath.join(' > '),\n status,\n duration: lastResult.duration,\n startedAt,\n completedAt,\n retryCount: test.results.length - 1,\n tags,\n failure,\n specFile,\n navigations,\n });\n } catch {\n // FR-026: never crash the test run\n }\n }\n\n onEnd(_result: PwFullResult): void {\n try {\n const completedAt = new Date().toISOString();\n const startedAtTime = new Date(this.startedAt).getTime();\n const completedAtTime = new Date(completedAt).getTime();\n const totalDuration = completedAtTime - startedAtTime;\n\n // Build timeline from navigation data\n const timeline = this.buildTimeline();\n\n // Build summary\n const summary = this.buildSummary();\n\n const report: TestRunReport = {\n schemaVersion: SCHEMA_VERSION,\n testRunId: this.testRunId,\n startedAt: this.startedAt,\n completedAt,\n totalDuration,\n summary,\n ci: detectCI(),\n metadata: this.config.metadata,\n timeline,\n shardRunIds: null,\n };\n\n this.writeReport(report);\n writeHtmlReport(report, this.config);\n } catch {\n // FR-026: never crash the test run\n }\n }\n\n printsToStdio(): boolean {\n return false;\n }\n\n private buildTimeline(): TimelineEntry[] {\n const entries: TimelineEntry[] = [];\n\n for (const test of this.collectedTests) {\n if (test.navigations.length === 0) {\n // No navigation data — create dummy entry\n entries.push({\n url: 'about:blank',\n navigationType: 'dummy',\n visitedAt: test.startedAt,\n duration: test.duration,\n specFile: test.specFile,\n domContentLoadedAt: null,\n networkIdleAt: null,\n networkStats: null,\n tests: [this.toTestResult(test)],\n });\n continue;\n }\n\n // Create timeline entry per navigation\n for (let i = 0; i < test.navigations.length; i++) {\n const nav = test.navigations[i];\n const nextNav = test.navigations[i + 1];\n\n // Apply navigation type filter\n if (this.config.navigationTypes !== null && !this.config.navigationTypes.includes(nav.navigationType)) {\n continue;\n }\n\n const navTime = new Date(nav.timestamp).getTime();\n const nextTime = nextNav\n ? new Date(nextNav.timestamp).getTime()\n : new Date(test.completedAt).getTime();\n const duration = nextTime - navTime;\n\n entries.push({\n url: nav.url,\n navigationType: nav.navigationType,\n visitedAt: nav.timestamp,\n duration: Math.max(0, duration),\n specFile: test.specFile,\n domContentLoadedAt: nav.domContentLoadedAt ?? null,\n networkIdleAt: nav.networkIdleAt ?? null,\n networkStats: nav.networkStats ?? null,\n tests: [this.toTestResult(test)],\n });\n }\n }\n\n // Sort chronologically\n entries.sort((a, b) => new Date(a.visitedAt).getTime() - new Date(b.visitedAt).getTime());\n\n return entries;\n }\n\n private buildSummary(): Summary {\n let passed = 0;\n let failed = 0;\n let flaky = 0;\n let skipped = 0;\n\n for (const test of this.collectedTests) {\n switch (test.status) {\n case 'passed': passed++; break;\n case 'failed': failed++; break;\n case 'flaky': flaky++; break;\n }\n }\n\n return {\n total: this.collectedTests.length,\n passed,\n failed,\n flaky,\n skipped,\n };\n }\n\n private toTestResult(test: CollectedTest): TRTestResult {\n return {\n title: test.title,\n status: test.status,\n duration: test.duration,\n startedAt: test.startedAt,\n completedAt: test.completedAt,\n retryCount: test.retryCount,\n tags: test.tags,\n failure: test.failure,\n };\n }\n\n private writeReport(report: TestRunReport): void {\n try {\n const json = JSON.stringify(report, null, 2);\n const outputPath = this.config.outputPath;\n const dir = dirname(outputPath);\n\n mkdirSync(dir, { recursive: true });\n\n // Atomic write: write to temp, then rename\n const tmpPath = outputPath + '.tmp';\n writeFileSync(tmpPath, json, 'utf-8');\n renameSync(tmpPath, outputPath);\n } catch (err) {\n // FR-026: log to stderr, never crash\n process.stderr.write(\n `[testrelic] Failed to write report: ${err instanceof Error ? err.message : String(err)}\\n`,\n );\n }\n }\n}\n","/**\n * Config resolution with prototype pollution prevention.\n * Merges user options into defaults, freezes the result.\n */\n\nimport type { ReporterConfig, NavigationType } from '@testrelic/core';\nimport { isValidConfig, createError, ErrorCode } from '@testrelic/core';\n\nexport const DEFAULT_REDACTION_PATTERNS: (string | RegExp)[] = [\n /AKIA[A-Z0-9]{16}/g,\n /Bearer\\s+[A-Za-z0-9\\-._~+/]+=*/g,\n /-----BEGIN\\s+(RSA\\s+)?PRIVATE\\sKEY-----[\\s\\S]*?-----END/g,\n /\\/\\/[^:]+:[^@]+@/g,\n];\n\nexport interface ResolvedConfig {\n readonly outputPath: string;\n readonly includeStackTrace: boolean;\n readonly includeCodeSnippets: boolean;\n readonly codeContextLines: number;\n readonly includeNetworkStats: boolean;\n readonly navigationTypes: NavigationType[] | null;\n readonly redactPatterns: (string | RegExp)[];\n readonly testRunId: string | null;\n readonly metadata: Record<string, unknown> | null;\n readonly openReport: boolean;\n readonly htmlReportPath: string;\n}\n\nexport function resolveConfig(options?: Partial<ReporterConfig>): ResolvedConfig {\n if (options !== undefined && !isValidConfig(options)) {\n throw createError(ErrorCode.CONFIG_INVALID, 'Invalid reporter configuration');\n }\n\n // Prototype pollution prevention: merge onto Object.create(null)\n const target = Object.create(null) as Record<string, unknown>;\n target.outputPath = options?.outputPath ?? './test-results/analytics-timeline.json';\n target.includeStackTrace = options?.includeStackTrace ?? false;\n target.includeCodeSnippets = options?.includeCodeSnippets ?? true;\n target.codeContextLines = options?.codeContextLines ?? 3;\n target.includeNetworkStats = options?.includeNetworkStats ?? true;\n target.navigationTypes = options?.navigationTypes ?? null;\n target.redactPatterns = [\n ...DEFAULT_REDACTION_PATTERNS,\n ...(options?.redactPatterns ?? []),\n ];\n target.testRunId = options?.testRunId ?? null;\n target.metadata = options?.metadata ?? null;\n const outputPath = target.outputPath as string;\n target.openReport = options?.openReport ?? true;\n target.htmlReportPath = options?.htmlReportPath ?? outputPath.replace(/\\.json$/, '.html');\n\n return Object.freeze(target) as unknown as ResolvedConfig;\n}\n","/**\n * JSON schema version for the analytics timeline output.\n */\nexport const SCHEMA_VERSION = '1.0.0';\n","/**\n * Source file reading and code snippet extraction for failure diagnostics.\n * Never throws — returns null on any error.\n */\n\nimport { readFileSync } from 'node:fs';\n\nexport function extractCodeSnippet(\n filePath: string,\n line: number,\n contextLines: number,\n): string | null {\n try {\n const content = readFileSync(filePath, 'utf-8');\n const lines = content.split('\\n');\n\n if (line < 1 || line > lines.length) return null;\n\n const startLine = Math.max(1, line - contextLines);\n const endLine = Math.min(lines.length, line + contextLines);\n\n const snippetLines: string[] = [];\n for (let i = startLine; i <= endLine; i++) {\n const marker = i === line ? '>' : ' ';\n const lineNum = String(i).padStart(String(endLine).length, ' ');\n snippetLines.push(`${marker} ${lineNum} | ${lines[i - 1]}`);\n }\n\n return snippetLines.join('\\n');\n } catch {\n return null;\n }\n}\n","/**\n * Pattern-based redaction engine.\n * Replaces sensitive data with [REDACTED] before writing reports.\n */\n\nexport const DEFAULT_REDACTION_PATTERNS: (string | RegExp)[] = [\n /AKIA[A-Z0-9]{16}/g,\n /Bearer\\s+[A-Za-z0-9\\-._~+/]+=*/g,\n /-----BEGIN\\s+(RSA\\s+)?PRIVATE\\sKEY-----[\\s\\S]*?-----END/g,\n /\\/\\/[^:]+:[^@]+@/g,\n];\n\nexport function createRedactor(\n patterns: (string | RegExp)[],\n): (text: string) => string {\n return (text: string): string => {\n let result = text;\n for (const pattern of patterns) {\n if (typeof pattern === 'string') {\n // Escape special regex characters and create a global regex\n const escaped = pattern.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n result = result.replace(new RegExp(escaped, 'g'), '[REDACTED]');\n } else {\n // Clone the regex to ensure global flag and reset lastIndex\n const flags = pattern.flags.includes('g') ? pattern.flags : pattern.flags + 'g';\n const cloned = new RegExp(pattern.source, flags);\n result = result.replace(cloned, '[REDACTED]');\n }\n }\n return result;\n };\n}\n","/**\n * CI provider auto-detection via environment variables.\n * Strategy pattern: check providers in priority order, first match wins.\n */\n\nimport type { CIMetadata, CIProvider } from '@testrelic/core';\n\ntype DetectFn = (env: Record<string, string | undefined>) => CIMetadata | null;\n\nfunction detectGitHubActions(env: Record<string, string | undefined>): CIMetadata | null {\n if (env.GITHUB_ACTIONS !== 'true') return null;\n return {\n provider: 'github-actions',\n buildId: env.GITHUB_RUN_ID ?? null,\n commitSha: env.GITHUB_SHA ?? null,\n branch: env.GITHUB_REF_NAME ?? null,\n };\n}\n\nfunction detectGitLabCI(env: Record<string, string | undefined>): CIMetadata | null {\n if (env.GITLAB_CI !== 'true') return null;\n return {\n provider: 'gitlab-ci',\n buildId: env.CI_PIPELINE_ID ?? null,\n commitSha: env.CI_COMMIT_SHA ?? null,\n branch: env.CI_COMMIT_BRANCH ?? env.CI_COMMIT_REF_NAME ?? null,\n };\n}\n\nfunction detectJenkins(env: Record<string, string | undefined>): CIMetadata | null {\n if (!env.JENKINS_URL) return null;\n let branch = env.GIT_BRANCH ?? null;\n if (branch?.startsWith('origin/')) {\n branch = branch.slice('origin/'.length);\n }\n return {\n provider: 'jenkins',\n buildId: env.BUILD_ID ?? null,\n commitSha: env.GIT_COMMIT ?? null,\n branch,\n };\n}\n\nfunction detectCircleCI(env: Record<string, string | undefined>): CIMetadata | null {\n if (env.CIRCLECI !== 'true') return null;\n return {\n provider: 'circleci',\n buildId: env.CIRCLE_BUILD_NUM ?? null,\n commitSha: env.CIRCLE_SHA1 ?? null,\n branch: env.CIRCLE_BRANCH ?? null,\n };\n}\n\nconst detectors: DetectFn[] = [\n detectGitHubActions,\n detectGitLabCI,\n detectJenkins,\n detectCircleCI,\n];\n\nexport function detectCI(env?: Record<string, string | undefined>): CIMetadata | null {\n const envVars = env ?? process.env;\n for (const detect of detectors) {\n const result = detect(envVars);\n if (result) return result;\n }\n return null;\n}\n","/**\n * HTML Report Generator\n *\n * Generates a self-contained HTML report from a TestRunReport.\n * Utility functions for HTML escaping, ANSI stripping, and formatting.\n */\n\nimport { writeFileSync, renameSync, mkdirSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport type { TestRunReport } from '@testrelic/core';\nimport type { ResolvedConfig } from './config.js';\nimport { renderHtmlDocument } from './html-template.js';\nimport { openInBrowser } from './browser-open.js';\n\n// ---------------------------------------------------------------------------\n// Utility Functions\n// ---------------------------------------------------------------------------\n\nconst HTML_ESCAPE_MAP: Record<string, string> = {\n '&': '&amp;',\n '<': '&lt;',\n '>': '&gt;',\n '\"': '&quot;',\n \"'\": '&#39;',\n};\n\nexport function escapeHtml(str: string): string {\n return str.replace(/[&<>\"']/g, (ch) => HTML_ESCAPE_MAP[ch] ?? ch);\n}\n\n// SAFETY: Regex targets all ANSI SGR escape sequences (color/style codes)\nconst ANSI_REGEX = /\\u001b\\[[0-9;]*m/g;\n\nexport function stripAnsi(str: string): string {\n return str.replace(ANSI_REGEX, '');\n}\n\nexport function formatDuration(ms: number): string {\n if (ms < 1000) return `${Math.round(ms)}ms`;\n if (ms < 60_000) return `${(ms / 1000).toFixed(1)}s`;\n const minutes = Math.floor(ms / 60_000);\n const seconds = Math.round((ms % 60_000) / 1000);\n return seconds > 0 ? `${minutes}m ${seconds}s` : `${minutes}m`;\n}\n\nexport function formatBytes(bytes: number): string {\n if (bytes === 0) return '0 B';\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n}\n\n// ---------------------------------------------------------------------------\n// HTML Report Generation\n// ---------------------------------------------------------------------------\n\nexport function generateHtmlReport(report: TestRunReport): string {\n const reportJson = JSON.stringify(report);\n return renderHtmlDocument(reportJson);\n}\n\nexport function writeHtmlReport(report: TestRunReport, config: ResolvedConfig): void {\n try {\n const html = generateHtmlReport(report);\n const outputPath = config.htmlReportPath;\n const dir = dirname(outputPath);\n\n mkdirSync(dir, { recursive: true });\n\n // Atomic write: write to temp, then rename\n const tmpPath = outputPath + '.tmp';\n writeFileSync(tmpPath, html, 'utf-8');\n renameSync(tmpPath, outputPath);\n\n // Auto-open in browser if configured and not in CI\n if (config.openReport && report.ci === null) {\n const absolutePath = resolve(outputPath);\n openInBrowser(absolutePath);\n }\n } catch (err) {\n // FR-026: log to stderr, never crash\n process.stderr.write(\n `[testrelic] Failed to write HTML report: ${err instanceof Error ? err.message : String(err)}\\n`,\n );\n }\n}\n","/**\n * HTML Template for TestRelic Report\n *\n * Renders a self-contained HTML document with embedded CSS, JS, and SVG.\n * The JSON report data is embedded in a <script type=\"application/json\"> tag\n * and rendered client-side for interactivity.\n */\n\nconst LOGO_SVG = `<svg width=\"32\" height=\"40\" viewBox=\"0 0 196 247\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M4.75 1.08009C2.034 2.66209 -0.130999 7.63009 0.610001 10.5821C0.969001 12.0121 3.021 15.2131 5.17 17.6971C14.375 28.3321 18 39.7791 18 58.2101V71.0001H12.434C1.16501 71.0001 0 73.4641 0 97.3051C0 106.858 0.298003 128.922 0.662003 146.337L1.323 178H33.606C65.786 178 65.897 178.007 68.544 180.284C72.228 183.453 72.244 189.21 68.579 192.877L65.957 195.5L33.479 195.801L1 196.103V204.551V213H24.577H48.154L51.077 215.923C55.007 219.853 55.007 224.147 51.077 228.077L48.154 231H26.469H4.783L5.41901 233.534C5.76901 234.927 7.143 238.527 8.472 241.534L10.89 247H40.945H71L71.006 241.75C71.017 230.748 76.027 221.606 84.697 216.767C97.854 209.424 114.086 213.895 121.323 226.857C123.659 231.041 124.418 233.833 124.789 239.607L125.263 247H155.187H185.11L187.528 241.534C188.857 238.527 190.231 234.927 190.581 233.534L191.217 231H169.531H147.846L144.923 228.077C142.928 226.082 142 224.152 142 222C142 219.848 142.928 217.918 144.923 215.923L147.846 213H171.423H195V204.551V196.103L162.521 195.801L130.043 195.5L127.421 192.877C123.991 189.445 123.835 183.869 127.074 180.421L129.349 178H162.013H194.677L195.338 146.337C195.702 128.922 196 106.858 196 97.3051C196 73.4641 194.835 71.0001 183.566 71.0001H178V58.2101C178 39.6501 181.397 28.7731 190.538 18.0651C195.631 12.0971 196.572 9.00809 194.511 5.02109C192.672 1.46509 190.197 9.12233e-05 186.028 9.12233e-05C179.761 9.12233e-05 168.713 14.8831 163.388 30.5001C160.975 37.5771 160.608 40.3751 160.213 54.7501L159.765 71.0001H150.732H141.7L142.286 53.2501C142.904 34.5511 144.727 24.3761 148.938 16.1211C151.823 10.4671 151.628 5.90109 148.364 2.63609C145 -0.726907 140.105 -0.887909 136.596 2.25009C133.481 5.03609 128.686 17.0811 126.507 27.5921C125.569 32.1191 124.617 43.0901 124.28 53.2501L123.69 71.0001H115.345H107V38.4231V5.84609L104.077 2.92309C102.082 0.928088 100.152 9.12233e-05 98 9.12233e-05C95.848 9.12233e-05 93.918 0.928088 91.923 2.92309L89 5.84609V38.4231V71.0001H80.655H72.31L71.72 53.2501C71.383 43.0901 70.431 32.1191 69.493 27.5921C67.314 17.0811 62.519 5.03609 59.404 2.25009C55.998 -0.795909 51.059 -0.710905 47.646 2.45209C44.221 5.62609 44.191 9.92109 47.539 17.4911C51.71 26.9241 53.007 34.4791 53.676 53.2501L54.31 71.0001H45.272H36.235L35.787 54.7501C35.392 40.3751 35.025 37.5771 32.612 30.5001C27.194 14.6091 16.228 -0.02891 9.787 0.03009C7.979 0.04709 5.712 0.519093 4.75 1.08009ZM42.687 108.974C33.431 112.591 20.036 125.024 18.408 131.512C17.476 135.223 20.677 140.453 28.253 147.599C37.495 156.319 44.191 159.471 53.5 159.485C59.317 159.494 61.645 158.953 67.274 156.289C77.634 151.385 88.987 139.161 88.996 132.9C89.004 127.304 76.787 114.707 66.745 109.956C59.16 106.368 50.285 106.006 42.687 108.974ZM129.255 109.904C119.151 114.768 106.996 127.33 107.004 132.9C107.013 139.108 118.562 151.475 128.939 156.389C134.338 158.945 136.744 159.496 142.521 159.498C152.526 159.501 160.369 155.502 169.771 145.605C180.444 134.368 180.278 130.975 168.486 119.388C160.043 111.094 152.727 107.595 143 107.201C136.364 106.933 134.78 107.244 129.255 109.904ZM48.5 125.922C46.3 126.969 43.152 128.945 41.505 130.314L38.511 132.802L40.504 135.005C41.601 136.216 44.434 138.342 46.8 139.728C52.577 143.114 57.36 142.466 64.009 137.395L68.978 133.606L66.756 131.24C60.944 125.054 54.357 123.135 48.5 125.922ZM138.386 125.063C136.674 125.571 133.375 127.677 131.057 129.743L126.841 133.5L131.901 137.343C138.65 142.468 143.407 143.124 149.2 139.728C151.566 138.342 154.351 136.269 155.389 135.122C157.684 132.587 156.742 131.097 150.58 127.511C145.438 124.519 142.329 123.895 138.386 125.063ZM91.923 162.923C89.043 165.804 89 166.008 89 176.973C89 184.805 89.435 188.941 90.47 190.941C92.356 194.589 96.918 196.273 101.03 194.84C105.82 193.17 107 189.638 107 176.973C107 166.008 106.957 165.804 104.077 162.923C102.082 160.928 100.152 160 98 160C95.848 160 93.918 160.928 91.923 162.923ZM94.5 232.155C91.026 234.055 90 236.229 90 241.691V247H98H106V242.082C106 235.732 105.37 234.242 101.928 232.463C98.591 230.737 97.197 230.679 94.5 232.155Z\" fill=\"url(#paint0_linear_55_11)\"/>\n<defs><linearGradient id=\"paint0_linear_55_11\" x1=\"98\" y1=\"0.000244141\" x2=\"98\" y2=\"247\" gradientUnits=\"userSpaceOnUse\">\n<stop stop-color=\"#03B79C\"/><stop offset=\"0.504808\" stop-color=\"#4EDAA4\"/><stop offset=\"0.865285\" stop-color=\"#84F3AA\"/>\n</linearGradient></defs></svg>`;\n\nconst CSS = `\n*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}\nbody{font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,sans-serif;\n color:#171717;background:#fff;line-height:1.6;-webkit-font-smoothing:antialiased}\n.container{max-width:1100px;margin:0 auto;padding:24px 20px}\n/* Header */\n.header{display:flex;align-items:center;gap:12px;margin-bottom:8px}\n.header svg{flex-shrink:0}\n.header h1{font-size:22px;font-weight:700;color:#171717}\n.meta{display:flex;flex-wrap:wrap;gap:8px 20px;font-size:13px;color:#6b7280;margin-bottom:20px}\n.meta-item{display:flex;align-items:center;gap:4px}\n.meta-label{font-weight:600;color:#374151}\n.run-id{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;\n background:#f3f4f6;padding:2px 8px;border-radius:4px}\n.ci-badge{display:inline-flex;align-items:center;gap:4px;background:#eff6ff;\n color:#1d4ed8;padding:2px 8px;border-radius:4px;font-size:12px;font-weight:500}\n.merged-badge{background:#fef3c7;color:#92400e;padding:2px 8px;border-radius:4px;\n font-size:12px;font-weight:500}\n/* Summary Cards */\n.summary{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:12px;margin-bottom:28px}\n.summary-card{border-radius:10px;padding:16px;text-align:center;border:1px solid #e5e7eb}\n.summary-card .count{font-size:32px;font-weight:800;line-height:1.1}\n.summary-card .label{font-size:13px;font-weight:500;color:#6b7280;margin-top:2px}\n.card-passed{border-color:#bbf7d0;background:#f0fdf4}.card-passed .count{color:#16a34a}\n.card-failed{border-color:#fecaca;background:#fef2f2}.card-failed .count{color:#dc2626}\n.card-flaky{border-color:#fde68a;background:#fffbeb}.card-flaky .count{color:#d97706}\n.card-skipped{border-color:#e5e7eb;background:#f9fafb}.card-skipped .count{color:#6b7280}\n.card-total{border-color:#c7d2fe;background:#eef2ff}.card-total .count{color:#4f46e5}\n/* Timeline */\n.timeline{display:flex;flex-direction:column;gap:8px}\n.timeline-entry{border:1px solid #e5e7eb;border-radius:10px;overflow:hidden;\n border-left:4px solid #e5e7eb;transition:border-color .15s}\n.timeline-entry:hover{border-color:#d1d5db}\n.timeline-entry--has-failures{border-left-color:#ef4444}\n.timeline-entry--has-failures:hover{border-color:#fca5a5}\n.timeline-header{display:flex;align-items:center;gap:10px;padding:12px 16px;cursor:pointer;\n user-select:none;background:#fafafa;transition:background .15s}\n.timeline-header:hover{background:#f3f4f6}\n.chevron{width:16px;height:16px;flex-shrink:0;transition:transform .2s;color:#9ca3af}\n.timeline-entry.expanded .chevron{transform:rotate(90deg)}\n.timeline-url{font-size:14px;font-weight:600;color:#171717;overflow:hidden;\n text-overflow:ellipsis;white-space:nowrap;max-width:500px;min-width:0}\n.nav-type-badge{font-size:11px;font-weight:600;padding:2px 8px;border-radius:9999px;\n white-space:nowrap;text-transform:uppercase;letter-spacing:.02em;flex-shrink:0}\n.badge-goto,.badge-navigation,.badge-page_load{background:#d1fae5;color:#065f46}\n.badge-back,.badge-forward{background:#dbeafe;color:#1e40af}\n.badge-spa_route,.badge-spa_replace,.badge-hash_change,.badge-popstate{background:#ede9fe;color:#5b21b6}\n.badge-link_click,.badge-form_submit{background:#fce7f3;color:#9d174d}\n.badge-redirect{background:#ffedd5;color:#9a3412}\n.badge-refresh{background:#e0f2fe;color:#075985}\n.badge-dummy,.badge-fallback,.badge-manual_record{background:#f3f4f6;color:#6b7280}\n.timeline-info{display:flex;align-items:center;gap:8px;font-size:12px;color:#6b7280;\n margin-left:auto;flex-shrink:0;white-space:nowrap}\n.spec-file{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11px;\n color:#6b7280;background:#f3f4f6;padding:1px 6px;border-radius:3px}\n.timeline-content{display:none;padding:0 16px 16px;border-top:1px solid #f3f4f6}\n.timeline-entry.expanded .timeline-content{display:block}\n/* Test Cards */\n.tests-section{margin-top:12px}\n.spec-summary{font-size:12px;color:#6b7280;margin-bottom:8px;display:flex;gap:12px;flex-wrap:wrap}\n.spec-summary span{font-weight:600}\n.spec-passed{color:#16a34a}.spec-failed{color:#dc2626}.spec-flaky{color:#d97706}\n.test-card{display:flex;align-items:flex-start;gap:8px;padding:8px 0;\n border-bottom:1px solid #f3f4f6}\n.test-card:last-child{border-bottom:none}\n.status-badge{font-size:11px;font-weight:700;padding:2px 8px;border-radius:9999px;\n flex-shrink:0;margin-top:2px;text-transform:uppercase;letter-spacing:.03em}\n.status-passed{background:#d1fae5;color:#065f46}\n.status-failed{background:#fecaca;color:#991b1b}\n.status-flaky{background:#fde68a;color:#92400e}\n.test-info{flex:1;min-width:0}\n.test-title{font-size:13px;color:#171717;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.test-meta{display:flex;gap:8px;align-items:center;margin-top:2px;font-size:11px;color:#9ca3af}\n.retry-badge{background:#fef3c7;color:#92400e;padding:1px 5px;border-radius:3px;font-size:10px;font-weight:600}\n.tag-badge{background:#eff6ff;color:#1d4ed8;padding:1px 5px;border-radius:3px;font-size:10px}\n.test-duration{font-size:12px;color:#9ca3af;flex-shrink:0;margin-top:2px}\n/* Failure Details */\n.failure-toggle{font-size:12px;color:#03b79c;cursor:pointer;margin-top:4px;\n border:none;background:none;padding:0;text-decoration:underline;font-family:inherit}\n.failure-toggle:hover{color:#028a75}\n.failure-details{display:none;margin-top:8px;border-radius:8px;overflow:hidden;\n border:1px solid #e5e7eb}\n.failure-details.show{display:block}\n.failure-message{padding:12px;background:#171717;color:#f8f8f8;font-size:12px;\n font-family:ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre-wrap;\n word-break:break-word;line-height:1.5;overflow-x:auto}\n.code-snippet{background:#1e1e1e;padding:0;font-size:12px;\n font-family:ui-monospace,SFMono-Regular,Menlo,monospace;overflow-x:auto}\n.code-line{display:flex;padding:0 12px;line-height:1.7}\n.code-line.highlight{background:rgba(239,68,68,.2)}\n.line-num{color:#6b7280;min-width:40px;text-align:right;padding-right:12px;\n user-select:none;flex-shrink:0}\n.line-code{color:#d4d4d4;white-space:pre;overflow-x:auto}\n.stack-toggle{font-size:11px;color:#6b7280;cursor:pointer;padding:8px 12px;\n border:none;background:#f9fafb;width:100%;text-align:left;font-family:inherit;\n border-top:1px solid #e5e7eb}\n.stack-toggle:hover{background:#f3f4f6;color:#374151}\n.stack-trace{display:none;padding:12px;background:#fafafa;font-size:11px;\n font-family:ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre-wrap;\n word-break:break-word;color:#6b7280;border-top:1px solid #e5e7eb;max-height:300px;overflow-y:auto}\n.stack-trace.show{display:block}\n/* Network Panel */\n.network-panel{margin-top:16px;border:1px solid #e5e7eb;border-radius:8px;overflow:hidden}\n.network-header{font-size:12px;font-weight:600;color:#374151;padding:10px 12px;\n background:#f9fafb;border-bottom:1px solid #e5e7eb;display:flex;align-items:center;gap:6px}\n.network-summary{display:flex;gap:16px;padding:10px 12px;font-size:12px;flex-wrap:wrap}\n.net-stat{display:flex;flex-direction:column;align-items:center;gap:1px}\n.net-stat .val{font-weight:700;font-size:14px;color:#171717}\n.net-stat .lbl{color:#9ca3af;font-size:11px}\n.net-stat.has-failed .val{color:#dc2626}\n.resource-breakdown{display:flex;gap:6px;padding:8px 12px;flex-wrap:wrap;border-top:1px solid #f3f4f6}\n.resource-type{display:flex;align-items:center;gap:4px;font-size:11px;padding:3px 8px;\n border-radius:4px;background:#f3f4f6;color:#374151}\n.resource-type .rt-count{font-weight:700}\n.resource-type--zero{opacity:.45}\n/* Empty State */\n.empty-state{text-align:center;padding:60px 20px;color:#9ca3af}\n.empty-state svg{width:48px;height:48px;margin-bottom:12px;opacity:.4}\n.empty-state p{font-size:15px;font-weight:500}\n/* No-network */\n.no-network{font-size:12px;color:#9ca3af;padding:10px 12px;font-style:italic}\n/* Section title */\n.section-title{font-size:16px;font-weight:700;color:#171717;margin-bottom:12px;\n display:flex;align-items:center;gap:8px}\n.section-title::before{content:'';width:4px;height:18px;background:#03b79c;border-radius:2px}\n`;\n\nconst JS = `\n(function(){\n var data=JSON.parse(document.getElementById('report-data').textContent);\n\n function esc(s){if(!s)return '';return s.replace(/&/g,'&amp;').replace(/</g,'&lt;')\n .replace(/>/g,'&gt;').replace(/\"/g,'&quot;').replace(/'/g,'&#39;')}\n function stripAnsi(s){return s?s.replace(/\\\\u001b\\\\[[0-9;]*m/g,'').replace(/\\\\x1b\\\\[[0-9;]*m/g,''):''}\n function fmtDur(ms){if(ms<1000)return Math.round(ms)+'ms';\n if(ms<60000)return (ms/1000).toFixed(1)+'s';\n var m=Math.floor(ms/60000),s=Math.round((ms%60000)/1000);\n return s>0?m+'m '+s+'s':m+'m'}\n function fmtBytes(b){if(b===0)return '0 B';if(b<1024)return b+' B';\n if(b<1048576)return (b/1024).toFixed(1)+' KB';return (b/1048576).toFixed(1)+' MB'}\n function fmtTime(iso){try{return new Date(iso).toLocaleString()}catch(e){return iso}}\n\n var app=document.getElementById('app');\n\n // Header\n var h='<div class=\"header\">__LOGO_SVG__<h1>TestRelic Report</h1></div>';\n h+='<div class=\"meta\">';\n h+='<div class=\"meta-item\"><span class=\"meta-label\">Run ID</span><span class=\"run-id\">'+esc(data.testRunId)+'</span></div>';\n h+='<div class=\"meta-item\"><span class=\"meta-label\">Started</span>'+fmtTime(data.startedAt)+'</div>';\n h+='<div class=\"meta-item\"><span class=\"meta-label\">Completed</span>'+fmtTime(data.completedAt)+'</div>';\n h+='<div class=\"meta-item\"><span class=\"meta-label\">Duration</span>'+fmtDur(data.totalDuration)+'</div>';\n if(data.ci){\n h+='<div class=\"meta-item\"><span class=\"ci-badge\">'+esc(data.ci.provider)+'</span></div>';\n if(data.ci.branch)h+='<div class=\"meta-item\"><span class=\"meta-label\">Branch</span>'+esc(data.ci.branch)+'</div>';\n if(data.ci.commitSha)h+='<div class=\"meta-item\"><span class=\"meta-label\">Commit</span><span class=\"run-id\">'+esc(data.ci.commitSha.substring(0,8))+'</span></div>';\n if(data.ci.buildId)h+='<div class=\"meta-item\"><span class=\"meta-label\">Build</span>'+esc(data.ci.buildId)+'</div>';\n }\n if(data.shardRunIds&&data.shardRunIds.length>0){\n h+='<div class=\"meta-item\"><span class=\"merged-badge\">Merged Report ('+data.shardRunIds.length+' shards)</span></div>';\n }\n h+='</div>';\n\n // Summary\n var s=data.summary;\n h+='<div class=\"summary\">';\n h+='<div class=\"summary-card card-total\"><div class=\"count\">'+s.total+'</div><div class=\"label\">Total</div></div>';\n h+='<div class=\"summary-card card-passed\"><div class=\"count\">'+s.passed+'</div><div class=\"label\">Passed</div></div>';\n h+='<div class=\"summary-card card-failed\"><div class=\"count\">'+s.failed+'</div><div class=\"label\">Failed</div></div>';\n h+='<div class=\"summary-card card-flaky\"><div class=\"count\">'+s.flaky+'</div><div class=\"label\">Flaky</div></div>';\n h+='<div class=\"summary-card card-skipped\"><div class=\"count\">'+s.skipped+'</div><div class=\"label\">Skipped</div></div>';\n h+='</div>';\n\n // Timeline\n h+='<div class=\"section-title\">Navigation Timeline</div>';\n if(data.timeline.length===0){\n h+='<div class=\"empty-state\">__LOGO_SVG__<p>No test data recorded</p></div>';\n }else{\n h+='<div class=\"timeline\" id=\"timeline\">';\n for(var i=0;i<data.timeline.length;i++){\n var e=data.timeline[i];\n var hasFail=e.tests.some(function(t){return t.status==='failed'});\n var cls='timeline-entry'+(hasFail?' timeline-entry--has-failures':'');\n h+='<div class=\"'+cls+'\" data-idx=\"'+i+'\">';\n h+='<div class=\"timeline-header\" onclick=\"toggleEntry(this)\">';\n h+='<svg class=\"chevron\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M9 18l6-6-6-6\"/></svg>';\n h+='<span class=\"timeline-url\" title=\"'+esc(e.url)+'\">'+esc(e.url)+'</span>';\n h+='<span class=\"nav-type-badge badge-'+e.navigationType+'\">'+esc(e.navigationType.replace(/_/g,' '))+'</span>';\n h+='<div class=\"timeline-info\">';\n h+='<span class=\"spec-file\">'+esc(e.specFile)+'</span>';\n h+='<span>'+fmtTime(e.visitedAt)+'</span>';\n h+='<span>'+fmtDur(e.duration)+'</span>';\n h+='</div></div>';\n h+='<div class=\"timeline-content\">';\n h+=renderTests(e.tests);\n h+=renderNetwork(e.networkStats);\n h+='</div></div>';\n }\n h+='</div>';\n }\n\n app.innerHTML=h;\n\n function renderTests(tests){\n if(!tests||tests.length===0)return '';\n var out='<div class=\"tests-section\">';\n // Spec summary\n var pc=0,fc=0,fkc=0;\n tests.forEach(function(t){if(t.status==='passed')pc++;else if(t.status==='failed')fc++;else if(t.status==='flaky')fkc++});\n out+='<div class=\"spec-summary\">';\n if(pc>0)out+='<span class=\"spec-passed\">'+pc+' passed</span>';\n if(fc>0)out+='<span class=\"spec-failed\">'+fc+' failed</span>';\n if(fkc>0)out+='<span class=\"spec-flaky\">'+fkc+' flaky</span>';\n out+='</div>';\n for(var j=0;j<tests.length;j++){\n var t=tests[j];\n out+='<div class=\"test-card\">';\n out+='<span class=\"status-badge status-'+t.status+'\">'+t.status+'</span>';\n out+='<div class=\"test-info\">';\n out+='<div class=\"test-title\" title=\"'+esc(t.title)+'\">'+esc(t.title)+'</div>';\n out+='<div class=\"test-meta\">';\n if(t.retryCount>0)out+='<span class=\"retry-badge\">'+t.retryCount+' retries</span>';\n if(t.tags)t.tags.forEach(function(tag){if(tag)out+='<span class=\"tag-badge\">'+esc(tag)+'</span>'});\n out+='</div>';\n if((t.status==='failed'||t.status==='flaky')&&t.failure){\n var fid='fail-'+Math.random().toString(36).substr(2,9);\n out+='<button class=\"failure-toggle\" onclick=\"toggleFail(\\\\''+fid+'\\\\')\">Show details</button>';\n out+='<div class=\"failure-details\" id=\"'+fid+'\">';\n out+='<div class=\"failure-message\">'+esc(stripAnsi(t.failure.message))+'</div>';\n if(t.failure.code){\n out+=renderCodeSnippet(t.failure.code,t.failure.line);\n }\n if(t.failure.line!==null){\n out+='<div style=\"padding:4px 12px;font-size:11px;color:#9ca3af;background:#f9fafb\">Line '+t.failure.line+'</div>';\n }\n if(t.failure.stack){\n var sid='stack-'+Math.random().toString(36).substr(2,9);\n out+='<button class=\"stack-toggle\" onclick=\"toggleStack(\\\\''+sid+'\\\\')\">Show stack trace</button>';\n out+='<div class=\"stack-trace\" id=\"'+sid+'\">'+esc(stripAnsi(t.failure.stack))+'</div>';\n }\n out+='</div>';\n } else if(t.status==='failed'&&!t.failure){\n out+='<div style=\"margin-top:4px;font-size:12px;color:#9ca3af;font-style:italic\">No diagnostic information available</div>';\n }\n out+='</div>';\n out+='<span class=\"test-duration\">'+fmtDur(t.duration)+'</span>';\n out+='</div>';\n }\n out+='</div>';\n return out;\n }\n\n function renderCodeSnippet(code,failLine){\n var lines=code.split('\\\\n');\n var out='<div class=\"code-snippet\">';\n for(var k=0;k<lines.length;k++){\n var raw=lines[k];\n var numMatch=raw.match(/^\\\\s*(>?\\\\s*)(\\\\d+)\\\\s*\\\\|/);\n var lineNum=numMatch?numMatch[2]:'';\n var isHighlight=raw.trimStart().startsWith('>');\n var codePart=raw.replace(/^\\\\s*>?\\\\s*\\\\d+\\\\s*\\\\|/,'');\n out+='<div class=\"code-line'+(isHighlight?' highlight':'')+'\">';\n out+='<span class=\"line-num\">'+esc(lineNum)+'</span>';\n out+='<span class=\"line-code\">'+esc(codePart)+'</span>';\n out+='</div>';\n }\n out+='</div>';\n return out;\n }\n\n function renderNetwork(stats){\n if(!stats)return '<div class=\"no-network\">No network data captured</div>';\n var out='<div class=\"network-panel\">';\n out+='<div class=\"network-header\"><svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M22 12h-4l-3 9L9 3l-3 9H2\"/></svg>Network</div>';\n out+='<div class=\"network-summary\">';\n out+='<div class=\"net-stat\"><span class=\"val\">'+stats.totalRequests+'</span><span class=\"lbl\">Requests</span></div>';\n out+='<div class=\"net-stat'+(stats.failedRequests>0?' has-failed':'')+'\"><span class=\"val\">'+stats.failedRequests+'</span><span class=\"lbl\">Failed</span></div>';\n out+='<div class=\"net-stat\"><span class=\"val\">'+fmtBytes(stats.totalBytes)+'</span><span class=\"lbl\">Transferred</span></div>';\n out+='</div>';\n if(stats.byType){\n var types=[['XHR','xhr'],['Document','document'],['Script','script'],['Stylesheet','stylesheet'],['Image','image'],['Font','font'],['Other','other']];\n out+='<div class=\"resource-breakdown\">';\n for(var ti=0;ti<types.length;ti++){\n var cnt=stats.byType[types[ti][1]]||0;\n out+='<div class=\"resource-type'+(cnt===0?' resource-type--zero':'')+'\"><span class=\"rt-count\">'+cnt+'</span> '+types[ti][0]+'</div>';\n }\n out+='</div>';\n }\n out+='</div>';\n return out;\n }\n\n})();\n\nfunction toggleEntry(el){el.closest('.timeline-entry').classList.toggle('expanded')}\nfunction toggleFail(id){document.getElementById(id).classList.toggle('show')}\nfunction toggleStack(id){document.getElementById(id).classList.toggle('show')}\n`;\n\nexport function renderHtmlDocument(reportJson: string): string {\n // Replace placeholder with actual SVG in the JS string\n const jsWithLogo = JS.replace(/__LOGO_SVG__/g, LOGO_SVG.replace(/'/g, \"\\\\'\").replace(/\\n/g, ''));\n\n return `<!-- TestRelic Report — self-contained, no external dependencies -->\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n<meta http-equiv=\"Content-Security-Policy\" content=\"default-src 'none'; style-src 'unsafe-inline'; script-src 'unsafe-inline'; img-src data:;\">\n<title>TestRelic Report</title>\n<style>${CSS}</style>\n</head>\n<body>\n<div class=\"container\" id=\"app\"></div>\n<script id=\"report-data\" type=\"application/json\">${reportJson}</script>\n<script>${jsWithLogo}</script>\n</body>\n</html>`;\n}\n","/**\n * Cross-platform browser auto-open utility.\n *\n * Opens a file in the user's default browser.\n * Fire-and-forget — never throws, errors logged to stderr.\n */\n\nimport { exec } from 'node:child_process';\n\nexport function openInBrowser(filePath: string): void {\n try {\n const platform = process.platform;\n let command: string;\n\n if (platform === 'darwin') {\n command = `open \"${filePath}\"`;\n } else if (platform === 'win32') {\n command = `start \"\" \"${filePath}\"`;\n } else {\n command = `xdg-open \"${filePath}\"`;\n }\n\n exec(command, (err) => {\n if (err) {\n process.stderr.write(\n `[testrelic] Failed to open browser: ${err.message}\\n`,\n );\n }\n });\n } catch {\n // Never crash the reporter\n }\n}\n","/**\n * @testrelic/playwright-analytics — Main entry point\n *\n * Default export: TestRelicReporter class\n * Named export: recordNavigation helper\n */\n\nexport { default } from './reporter.js';\n\nexport type {\n NavigationType,\n TestRunReport,\n Summary,\n CIMetadata,\n TimelineEntry,\n TestResult,\n FailureDiagnostic,\n NetworkStats,\n ReporterConfig,\n} from './types.js';\n\nexport { SCHEMA_VERSION } from './schema.js';\n\nimport type { NavigationType, NavigationAnnotation } from '@testrelic/core';\n\nlet warned = false;\n\n/**\n * Records a manual navigation event in the current test's annotations.\n * Use for navigation the auto-tracker cannot detect (iframes, web workers).\n *\n * Requires access to the current test info. If not available, logs a\n * warning once and no-ops.\n */\nexport function recordNavigation(\n testInfo: { annotations: Array<{ type: string; description?: string }> } | null | undefined,\n url: string,\n navigationType: NavigationType = 'manual_record',\n): void {\n if (!testInfo || !testInfo.annotations) {\n if (!warned) {\n warned = true;\n process.stderr.write('[testrelic] recordNavigation: reporter not active, navigation not recorded\\n');\n }\n return;\n }\n\n const annotation: NavigationAnnotation = {\n url,\n navigationType,\n timestamp: new Date().toISOString(),\n };\n\n testInfo.annotations.push({\n type: 'lambdatest-navigation',\n description: JSON.stringify(annotation),\n });\n}\n"],"mappings":";AAOA,SAAS,kBAAkB;AAC3B,SAAS,aAAAA,YAAW,iBAAAC,gBAAe,cAAAC,mBAAkB;AACrD,SAAS,WAAAC,UAAS,gBAAgB;;;ACHlC,SAAS,eAAe,aAAa,iBAAiB;AAE/C,IAAM,6BAAkD;AAAA,EAC7D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAgBO,SAAS,cAAc,SAAmD;AAC/E,MAAI,YAAY,UAAa,CAAC,cAAc,OAAO,GAAG;AACpD,UAAM,YAAY,UAAU,gBAAgB,gCAAgC;AAAA,EAC9E;AAGA,QAAM,SAAS,uBAAO,OAAO,IAAI;AACjC,SAAO,aAAa,SAAS,cAAc;AAC3C,SAAO,oBAAoB,SAAS,qBAAqB;AACzD,SAAO,sBAAsB,SAAS,uBAAuB;AAC7D,SAAO,mBAAmB,SAAS,oBAAoB;AAC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AA,QACb,uCAAuC,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;AAAA;AAAA,MACzF;AAAA,IACF;AAAA,EACF;AACF;;;AS9TA,IAAI,SAAS;AASN,SAAS,iBACd,UACA,KACA,iBAAiC,iBAC3B;AACN,MAAI,CAAC,YAAY,CAAC,SAAS,aAAa;AACtC,QAAI,CAAC,QAAQ;AACX,eAAS;AACT,cAAQ,OAAO,MAAM,8EAA8E;AAAA,IACrG;AACA;AAAA,EACF;AAEA,QAAM,aAAmC;AAAA,IACvC;AAAA,IACA;AAAA,IACA,YAAW,oBAAI,KAAK,GAAE,YAAY;AAAA,EACpC;AAEA,WAAS,YAAY,KAAK;AAAA,IACxB,MAAM;AAAA,IACN,aAAa,KAAK,UAAU,UAAU;AAAA,EACxC,CAAC;AACH;","names":["mkdirSync","writeFileSync","renameSync","dirname","dirname","mkdirSync","writeFileSync","renameSync"]}
1
+ {"version":3,"sources":["../src/reporter.ts","../src/config.ts","../src/schema.ts","../src/code-extractor.ts","../src/redaction.ts","../src/ci-detector.ts","../src/html-report.ts","../src/html-template.ts","../src/browser-open.ts","../src/artifact-manager.ts","../src/index.ts"],"sourcesContent":["/**\n * TestRelicReporter — Playwright custom reporter\n *\n * Captures test execution data and produces a structured JSON timeline.\n * All hooks are wrapped in try/catch (FR-026): never crashes the test run.\n */\n\nimport { randomUUID, createHash } from 'node:crypto';\nimport { mkdirSync, writeFileSync, renameSync } from 'node:fs';\nimport { dirname, relative } from 'node:path';\nimport type {\n ReporterConfig,\n TestRunReport,\n Summary,\n TimelineEntry,\n TestResult as TRTestResult,\n TestArtifacts,\n NavigationAnnotation,\n FailureDiagnostic,\n TestStatus,\n TestType,\n} from '@testrelic/core';\nimport { resolveConfig } from './config.js';\nimport type { ResolvedConfig } from './config.js';\nimport { SCHEMA_VERSION } from './schema.js';\nimport { extractCodeSnippet } from './code-extractor.js';\nimport { createRedactor } from './redaction.js';\nimport { detectCI } from './ci-detector.js';\nimport { writeHtmlReport } from './html-report.js';\nimport { copyArtifacts } from './artifact-manager.js';\n\n// Playwright types — imported for type annotations only\ninterface PwFullConfig {\n rootDir: string;\n [key: string]: unknown;\n}\n\ninterface PwSuite {\n allTests(): PwTestCase[];\n}\n\ninterface PwTestCase {\n title: string;\n titlePath(): string[];\n annotations: Array<{ type: string; description?: string }>;\n tags?: string[];\n location: { file: string; line: number; column: number };\n results: PwTestResult[];\n outcome(): 'expected' | 'unexpected' | 'skipped' | 'flaky';\n expectedStatus: 'passed' | 'failed' | 'timedOut' | 'skipped' | 'interrupted';\n id: string;\n}\n\ninterface PwTestResult {\n status: 'passed' | 'failed' | 'timedOut' | 'skipped' | 'interrupted';\n duration: number;\n startTime: Date;\n retry: number;\n errors: PwTestError[];\n attachments: Array<{ name: string; contentType: string; path?: string; body?: Buffer }>;\n}\n\ninterface PwTestError {\n message?: string;\n stack?: string;\n location?: { file: string; line: number; column: number };\n snippet?: string;\n}\n\ninterface PwFullResult {\n status: 'passed' | 'failed' | 'timedout' | 'interrupted';\n startTime: Date;\n duration: number;\n}\n\n// ---------------------------------------------------------------------------\n// Helper functions (private to this module)\n// ---------------------------------------------------------------------------\n\nfunction mapPlaywrightStatus(status: string): TestStatus {\n switch (status) {\n case 'passed': return 'passed';\n case 'failed': return 'failed';\n case 'timedOut': return 'timedout';\n case 'skipped': return 'skipped';\n case 'interrupted': return 'failed';\n default: return 'failed';\n }\n}\n\nfunction generateTestId(filePath: string, suiteName: string, title: string): string {\n const input = `${filePath}::${suiteName}::${title}`;\n return createHash('sha256').update(input).digest('hex').substring(0, 16);\n}\n\nfunction getSuiteName(titlePath: string[]): string {\n // titlePath: ['', 'project', 'file.spec.ts', ...suites..., 'test title']\n // <= 4 elements means no describe block (root, project, file, test)\n if (titlePath.length <= 4) return '';\n return titlePath[titlePath.length - 2];\n}\n\nfunction getRetryStatus(results: PwTestResult[]): string | null {\n const passedIndex = results.findIndex((r) => r.status === 'passed');\n return passedIndex > 0 ? `passed on retry ${passedIndex}` : null;\n}\n\nfunction getTestType(tags: string[], filePath: string): TestType {\n const typeOrder: TestType[] = ['e2e', 'api', 'unit'];\n for (const type of typeOrder) {\n if (tags.some((tag) => tag === `@${type}` || tag === type)) {\n return type;\n }\n }\n for (const type of typeOrder) {\n if (filePath.includes(`/${type}/`)) {\n return type;\n }\n }\n return 'unknown';\n}\n\n// Internal state for collected test data\ninterface CollectedTest {\n titlePath: string[];\n title: string;\n status: TestStatus;\n duration: number;\n startedAt: string;\n completedAt: string;\n retryCount: number;\n tags: string[];\n failure: FailureDiagnostic | null;\n specFile: string;\n navigations: NavigationAnnotation[];\n testId: string;\n filePath: string;\n suiteName: string;\n testType: TestType;\n isFlaky: boolean;\n retryStatus: string | null;\n expectedStatus: TestStatus;\n actualStatus: TestStatus;\n artifacts: TestArtifacts | null;\n}\n\nexport default class TestRelicReporter {\n private config: ResolvedConfig;\n private rootDir = '';\n private startedAt = '';\n private testRunId = '';\n private collectedTests: CollectedTest[] = [];\n\n constructor(options?: Partial<ReporterConfig>) {\n this.config = resolveConfig(options);\n }\n\n onBegin(config: PwFullConfig, _suite: PwSuite): void {\n try {\n this.rootDir = config.rootDir;\n this.startedAt = new Date().toISOString();\n this.testRunId = this.config.testRunId ?? randomUUID();\n } catch {\n // FR-026: never crash the test run\n }\n }\n\n onTestEnd(test: PwTestCase, result: PwTestResult): void {\n try {\n const lastResult = result;\n const outcome = test.outcome();\n\n // Determine status using expanded mapping\n let status: TestStatus;\n if (outcome === 'flaky') {\n status = 'flaky';\n } else if (outcome === 'skipped') {\n status = 'skipped';\n } else {\n status = mapPlaywrightStatus(lastResult.status);\n }\n\n const startedAt = lastResult.startTime.toISOString();\n const completedAt = new Date(lastResult.startTime.getTime() + lastResult.duration).toISOString();\n\n // Extract tags: prefer test.tags (1.42+), fallback to annotations\n const tags = test.tags\n ? [...test.tags]\n : test.annotations\n .filter((a) => a.type === 'tag')\n .map((a) => a.description ?? '');\n\n // Extract navigation annotations\n const navigations = test.annotations\n .filter((a) => a.type === 'lambdatest-navigation' && a.description)\n .map((a) => {\n try {\n return JSON.parse(a.description!) as NavigationAnnotation;\n } catch {\n return null;\n }\n })\n .filter((n): n is NavigationAnnotation => n !== null);\n\n // Build failure diagnostic\n let failure: FailureDiagnostic | null = null;\n if (status === 'failed' || status === 'flaky') {\n const errors = status === 'flaky'\n ? (test.results.find((r) => r.status !== 'passed')?.errors ?? [])\n : lastResult.errors;\n const firstError = errors[0];\n if (firstError) {\n const redact = createRedactor(this.config.redactPatterns);\n const errorLine = firstError.location?.line ?? null;\n let codeSnippet: string | null = null;\n if (this.config.includeCodeSnippets && errorLine !== null && firstError.location?.file) {\n codeSnippet = extractCodeSnippet(\n firstError.location.file,\n errorLine,\n this.config.codeContextLines,\n );\n if (codeSnippet) codeSnippet = redact(codeSnippet);\n }\n\n failure = {\n message: redact(firstError.message ?? 'Unknown error'),\n line: errorLine,\n code: codeSnippet,\n stack: this.config.includeStackTrace ? (firstError.stack ? redact(firstError.stack) : null) : null,\n };\n }\n }\n\n const titlePath = test.titlePath().filter(Boolean);\n const specFile = relative(this.rootDir || '.', test.location.file);\n\n // Extract enhanced metadata\n const suiteName = getSuiteName(titlePath);\n const title = titlePath.join(' > ');\n const filePath = specFile;\n const testId = generateTestId(filePath, suiteName, title);\n const testType = getTestType(tags, filePath);\n const isFlaky = outcome === 'flaky';\n const retryStatus = getRetryStatus(test.results);\n const expectedStatus = mapPlaywrightStatus(test.expectedStatus);\n const actualStatus = mapPlaywrightStatus(lastResult.status);\n\n // Extract artifacts (screenshots/videos) from Playwright attachments\n let artifacts: TestArtifacts | null = null;\n if (this.config.includeArtifacts && status !== 'skipped' && lastResult.attachments) {\n const outputDir = dirname(this.config.outputPath);\n const lastTitle = titlePath[titlePath.length - 1] ?? test.title;\n artifacts = copyArtifacts(lastResult.attachments, lastTitle, lastResult.retry, outputDir);\n }\n\n this.collectedTests.push({\n titlePath,\n title,\n status,\n duration: lastResult.duration,\n startedAt,\n completedAt,\n retryCount: test.results.length - 1,\n tags,\n failure,\n specFile,\n navigations,\n testId,\n filePath,\n suiteName,\n testType,\n isFlaky,\n retryStatus,\n expectedStatus,\n actualStatus,\n artifacts,\n });\n } catch {\n // FR-026: never crash the test run\n }\n }\n\n onEnd(_result: PwFullResult): void {\n try {\n const completedAt = new Date().toISOString();\n const startedAtTime = new Date(this.startedAt).getTime();\n const completedAtTime = new Date(completedAt).getTime();\n const totalDuration = completedAtTime - startedAtTime;\n\n // Build timeline from navigation data\n const timeline = this.buildTimeline();\n\n // Build summary\n const summary = this.buildSummary();\n\n const report: TestRunReport = {\n schemaVersion: SCHEMA_VERSION,\n testRunId: this.testRunId,\n startedAt: this.startedAt,\n completedAt,\n totalDuration,\n summary,\n ci: detectCI(),\n metadata: this.config.metadata,\n timeline,\n shardRunIds: null,\n };\n\n this.writeReport(report);\n writeHtmlReport(report, this.config);\n } catch {\n // FR-026: never crash the test run\n }\n }\n\n printsToStdio(): boolean {\n return false;\n }\n\n private buildTimeline(): TimelineEntry[] {\n const entries: TimelineEntry[] = [];\n\n for (const test of this.collectedTests) {\n if (test.navigations.length === 0) {\n // No navigation data — create dummy entry\n entries.push({\n url: 'about:blank',\n navigationType: 'dummy',\n visitedAt: test.startedAt,\n duration: test.duration,\n specFile: test.specFile,\n domContentLoadedAt: null,\n networkIdleAt: null,\n networkStats: null,\n tests: [this.toTestResult(test)],\n });\n continue;\n }\n\n // Create timeline entry per navigation\n for (let i = 0; i < test.navigations.length; i++) {\n const nav = test.navigations[i];\n const nextNav = test.navigations[i + 1];\n\n // Apply navigation type filter\n if (this.config.navigationTypes !== null && !this.config.navigationTypes.includes(nav.navigationType)) {\n continue;\n }\n\n const navTime = new Date(nav.timestamp).getTime();\n const nextTime = nextNav\n ? new Date(nextNav.timestamp).getTime()\n : new Date(test.completedAt).getTime();\n const duration = nextTime - navTime;\n\n entries.push({\n url: nav.url,\n navigationType: nav.navigationType,\n visitedAt: nav.timestamp,\n duration: Math.max(0, duration),\n specFile: test.specFile,\n domContentLoadedAt: nav.domContentLoadedAt ?? null,\n networkIdleAt: nav.networkIdleAt ?? null,\n networkStats: nav.networkStats ?? null,\n tests: [this.toTestResult(test)],\n });\n }\n }\n\n // Sort chronologically\n entries.sort((a, b) => new Date(a.visitedAt).getTime() - new Date(b.visitedAt).getTime());\n\n return entries;\n }\n\n private buildSummary(): Summary {\n let passed = 0;\n let failed = 0;\n let flaky = 0;\n let skipped = 0;\n let timedout = 0;\n\n for (const test of this.collectedTests) {\n switch (test.status) {\n case 'passed': passed++; break;\n case 'failed': failed++; break;\n case 'flaky': flaky++; break;\n case 'skipped': skipped++; break;\n case 'timedout': timedout++; break;\n }\n }\n\n return {\n total: this.collectedTests.length,\n passed,\n failed,\n flaky,\n skipped,\n timedout,\n };\n }\n\n private toTestResult(test: CollectedTest): TRTestResult {\n return {\n title: test.title,\n status: test.status,\n duration: test.duration,\n startedAt: test.startedAt,\n completedAt: test.completedAt,\n retryCount: test.retryCount,\n tags: test.tags,\n failure: test.failure,\n testId: test.testId,\n filePath: test.filePath,\n suiteName: test.suiteName,\n testType: test.testType,\n isFlaky: test.isFlaky,\n retryStatus: test.retryStatus,\n expectedStatus: test.expectedStatus,\n actualStatus: test.actualStatus,\n artifacts: test.artifacts,\n };\n }\n\n private writeReport(report: TestRunReport): void {\n try {\n const json = JSON.stringify(report, null, 2);\n const outputPath = this.config.outputPath;\n const dir = dirname(outputPath);\n\n mkdirSync(dir, { recursive: true });\n\n // Atomic write: write to temp, then rename\n const tmpPath = outputPath + '.tmp';\n writeFileSync(tmpPath, json, 'utf-8');\n renameSync(tmpPath, outputPath);\n } catch (err) {\n // FR-026: log to stderr, never crash\n process.stderr.write(\n `[testrelic] Failed to write report: ${err instanceof Error ? err.message : String(err)}\\n`,\n );\n }\n }\n}\n","/**\n * Config resolution with prototype pollution prevention.\n * Merges user options into defaults, freezes the result.\n */\n\nimport type { ReporterConfig, NavigationType } from '@testrelic/core';\nimport { isValidConfig, createError, ErrorCode } from '@testrelic/core';\n\nexport const DEFAULT_REDACTION_PATTERNS: (string | RegExp)[] = [\n /AKIA[A-Z0-9]{16}/g,\n /Bearer\\s+[A-Za-z0-9\\-._~+/]+=*/g,\n /-----BEGIN\\s+(RSA\\s+)?PRIVATE\\sKEY-----[\\s\\S]*?-----END/g,\n /\\/\\/[^:]+:[^@]+@/g,\n];\n\nexport interface ResolvedConfig {\n readonly outputPath: string;\n readonly includeStackTrace: boolean;\n readonly includeCodeSnippets: boolean;\n readonly codeContextLines: number;\n readonly includeNetworkStats: boolean;\n readonly navigationTypes: NavigationType[] | null;\n readonly redactPatterns: (string | RegExp)[];\n readonly testRunId: string | null;\n readonly metadata: Record<string, unknown> | null;\n readonly openReport: boolean;\n readonly htmlReportPath: string;\n readonly includeArtifacts: boolean;\n}\n\nexport function resolveConfig(options?: Partial<ReporterConfig>): ResolvedConfig {\n if (options !== undefined && !isValidConfig(options)) {\n throw createError(ErrorCode.CONFIG_INVALID, 'Invalid reporter configuration');\n }\n\n // Prototype pollution prevention: merge onto Object.create(null)\n const target = Object.create(null) as Record<string, unknown>;\n target.outputPath = options?.outputPath ?? './test-results/analytics-timeline.json';\n target.includeStackTrace = options?.includeStackTrace ?? false;\n target.includeCodeSnippets = options?.includeCodeSnippets ?? true;\n target.codeContextLines = options?.codeContextLines ?? 3;\n target.includeNetworkStats = options?.includeNetworkStats ?? true;\n target.navigationTypes = options?.navigationTypes ?? null;\n target.redactPatterns = [\n ...DEFAULT_REDACTION_PATTERNS,\n ...(options?.redactPatterns ?? []),\n ];\n target.testRunId = options?.testRunId ?? null;\n target.metadata = options?.metadata ?? null;\n const outputPath = target.outputPath as string;\n target.openReport = options?.openReport ?? true;\n target.htmlReportPath = options?.htmlReportPath ?? outputPath.replace(/\\.json$/, '.html');\n target.includeArtifacts = options?.includeArtifacts ?? true;\n\n return Object.freeze(target) as unknown as ResolvedConfig;\n}\n","/**\n * JSON schema version for the analytics timeline output.\n */\nexport const SCHEMA_VERSION = '1.2.0';\n","/**\n * Source file reading and code snippet extraction for failure diagnostics.\n * Never throws — returns null on any error.\n */\n\nimport { readFileSync } from 'node:fs';\n\nexport function extractCodeSnippet(\n filePath: string,\n line: number,\n contextLines: number,\n): string | null {\n try {\n const content = readFileSync(filePath, 'utf-8');\n const lines = content.split('\\n');\n\n if (line < 1 || line > lines.length) return null;\n\n const startLine = Math.max(1, line - contextLines);\n const endLine = Math.min(lines.length, line + contextLines);\n\n const snippetLines: string[] = [];\n for (let i = startLine; i <= endLine; i++) {\n const marker = i === line ? '>' : ' ';\n const lineNum = String(i).padStart(String(endLine).length, ' ');\n snippetLines.push(`${marker} ${lineNum} | ${lines[i - 1]}`);\n }\n\n return snippetLines.join('\\n');\n } catch {\n return null;\n }\n}\n","/**\n * Pattern-based redaction engine.\n * Replaces sensitive data with [REDACTED] before writing reports.\n */\n\nexport const DEFAULT_REDACTION_PATTERNS: (string | RegExp)[] = [\n /AKIA[A-Z0-9]{16}/g,\n /Bearer\\s+[A-Za-z0-9\\-._~+/]+=*/g,\n /-----BEGIN\\s+(RSA\\s+)?PRIVATE\\sKEY-----[\\s\\S]*?-----END/g,\n /\\/\\/[^:]+:[^@]+@/g,\n];\n\nexport function createRedactor(\n patterns: (string | RegExp)[],\n): (text: string) => string {\n return (text: string): string => {\n let result = text;\n for (const pattern of patterns) {\n if (typeof pattern === 'string') {\n // Escape special regex characters and create a global regex\n const escaped = pattern.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n result = result.replace(new RegExp(escaped, 'g'), '[REDACTED]');\n } else {\n // Clone the regex to ensure global flag and reset lastIndex\n const flags = pattern.flags.includes('g') ? pattern.flags : pattern.flags + 'g';\n const cloned = new RegExp(pattern.source, flags);\n result = result.replace(cloned, '[REDACTED]');\n }\n }\n return result;\n };\n}\n","/**\n * CI provider auto-detection via environment variables.\n * Strategy pattern: check providers in priority order, first match wins.\n */\n\nimport type { CIMetadata, CIProvider } from '@testrelic/core';\n\ntype DetectFn = (env: Record<string, string | undefined>) => CIMetadata | null;\n\nfunction detectGitHubActions(env: Record<string, string | undefined>): CIMetadata | null {\n if (env.GITHUB_ACTIONS !== 'true') return null;\n return {\n provider: 'github-actions',\n buildId: env.GITHUB_RUN_ID ?? null,\n commitSha: env.GITHUB_SHA ?? null,\n branch: env.GITHUB_REF_NAME ?? null,\n };\n}\n\nfunction detectGitLabCI(env: Record<string, string | undefined>): CIMetadata | null {\n if (env.GITLAB_CI !== 'true') return null;\n return {\n provider: 'gitlab-ci',\n buildId: env.CI_PIPELINE_ID ?? null,\n commitSha: env.CI_COMMIT_SHA ?? null,\n branch: env.CI_COMMIT_BRANCH ?? env.CI_COMMIT_REF_NAME ?? null,\n };\n}\n\nfunction detectJenkins(env: Record<string, string | undefined>): CIMetadata | null {\n if (!env.JENKINS_URL) return null;\n let branch = env.GIT_BRANCH ?? null;\n if (branch?.startsWith('origin/')) {\n branch = branch.slice('origin/'.length);\n }\n return {\n provider: 'jenkins',\n buildId: env.BUILD_ID ?? null,\n commitSha: env.GIT_COMMIT ?? null,\n branch,\n };\n}\n\nfunction detectCircleCI(env: Record<string, string | undefined>): CIMetadata | null {\n if (env.CIRCLECI !== 'true') return null;\n return {\n provider: 'circleci',\n buildId: env.CIRCLE_BUILD_NUM ?? null,\n commitSha: env.CIRCLE_SHA1 ?? null,\n branch: env.CIRCLE_BRANCH ?? null,\n };\n}\n\nconst detectors: DetectFn[] = [\n detectGitHubActions,\n detectGitLabCI,\n detectJenkins,\n detectCircleCI,\n];\n\nexport function detectCI(env?: Record<string, string | undefined>): CIMetadata | null {\n const envVars = env ?? process.env;\n for (const detect of detectors) {\n const result = detect(envVars);\n if (result) return result;\n }\n return null;\n}\n","/**\n * HTML Report Generator\n *\n * Generates a self-contained HTML report from a TestRunReport.\n * Utility functions for HTML escaping, ANSI stripping, and formatting.\n */\n\nimport { writeFileSync, renameSync, mkdirSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport type { TestRunReport } from '@testrelic/core';\nimport type { ResolvedConfig } from './config.js';\nimport { renderHtmlDocument } from './html-template.js';\nimport { openInBrowser } from './browser-open.js';\n\n// ---------------------------------------------------------------------------\n// Utility Functions\n// ---------------------------------------------------------------------------\n\nconst HTML_ESCAPE_MAP: Record<string, string> = {\n '&': '&amp;',\n '<': '&lt;',\n '>': '&gt;',\n '\"': '&quot;',\n \"'\": '&#39;',\n};\n\nexport function escapeHtml(str: string): string {\n return str.replace(/[&<>\"']/g, (ch) => HTML_ESCAPE_MAP[ch] ?? ch);\n}\n\n// SAFETY: Regex targets all ANSI SGR escape sequences (color/style codes)\nconst ANSI_REGEX = /\\u001b\\[[0-9;]*m/g;\n\nexport function stripAnsi(str: string): string {\n return str.replace(ANSI_REGEX, '');\n}\n\nexport function formatDuration(ms: number): string {\n if (ms < 1000) return `${Math.round(ms)}ms`;\n if (ms < 60_000) return `${(ms / 1000).toFixed(1)}s`;\n const minutes = Math.floor(ms / 60_000);\n const seconds = Math.round((ms % 60_000) / 1000);\n return seconds > 0 ? `${minutes}m ${seconds}s` : `${minutes}m`;\n}\n\nexport function formatBytes(bytes: number): string {\n if (bytes === 0) return '0 B';\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n}\n\n// ---------------------------------------------------------------------------\n// HTML Report Generation\n// ---------------------------------------------------------------------------\n\nexport function generateHtmlReport(report: TestRunReport): string {\n const reportJson = JSON.stringify(report);\n return renderHtmlDocument(reportJson);\n}\n\nexport function writeHtmlReport(report: TestRunReport, config: ResolvedConfig): void {\n try {\n const html = generateHtmlReport(report);\n const outputPath = config.htmlReportPath;\n const dir = dirname(outputPath);\n\n mkdirSync(dir, { recursive: true });\n\n // Atomic write: write to temp, then rename\n const tmpPath = outputPath + '.tmp';\n writeFileSync(tmpPath, html, 'utf-8');\n renameSync(tmpPath, outputPath);\n\n // Auto-open in browser if configured and not in CI\n if (config.openReport && report.ci === null) {\n const absolutePath = resolve(outputPath);\n openInBrowser(absolutePath);\n }\n } catch (err) {\n // FR-026: log to stderr, never crash\n process.stderr.write(\n `[testrelic] Failed to write HTML report: ${err instanceof Error ? err.message : String(err)}\\n`,\n );\n }\n}\n","/**\n * HTML Template for TestRelic Report\n *\n * Renders a self-contained HTML document with embedded CSS, JS, and SVG.\n * The JSON report data is embedded in a <script type=\"application/json\"> tag\n * and rendered client-side for interactivity.\n */\n\nconst LOGO_SVG = `<svg width=\"32\" height=\"40\" viewBox=\"0 0 196 247\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M4.75 1.08009C2.034 2.66209 -0.130999 7.63009 0.610001 10.5821C0.969001 12.0121 3.021 15.2131 5.17 17.6971C14.375 28.3321 18 39.7791 18 58.2101V71.0001H12.434C1.16501 71.0001 0 73.4641 0 97.3051C0 106.858 0.298003 128.922 0.662003 146.337L1.323 178H33.606C65.786 178 65.897 178.007 68.544 180.284C72.228 183.453 72.244 189.21 68.579 192.877L65.957 195.5L33.479 195.801L1 196.103V204.551V213H24.577H48.154L51.077 215.923C55.007 219.853 55.007 224.147 51.077 228.077L48.154 231H26.469H4.783L5.41901 233.534C5.76901 234.927 7.143 238.527 8.472 241.534L10.89 247H40.945H71L71.006 241.75C71.017 230.748 76.027 221.606 84.697 216.767C97.854 209.424 114.086 213.895 121.323 226.857C123.659 231.041 124.418 233.833 124.789 239.607L125.263 247H155.187H185.11L187.528 241.534C188.857 238.527 190.231 234.927 190.581 233.534L191.217 231H169.531H147.846L144.923 228.077C142.928 226.082 142 224.152 142 222C142 219.848 142.928 217.918 144.923 215.923L147.846 213H171.423H195V204.551V196.103L162.521 195.801L130.043 195.5L127.421 192.877C123.991 189.445 123.835 183.869 127.074 180.421L129.349 178H162.013H194.677L195.338 146.337C195.702 128.922 196 106.858 196 97.3051C196 73.4641 194.835 71.0001 183.566 71.0001H178V58.2101C178 39.6501 181.397 28.7731 190.538 18.0651C195.631 12.0971 196.572 9.00809 194.511 5.02109C192.672 1.46509 190.197 9.12233e-05 186.028 9.12233e-05C179.761 9.12233e-05 168.713 14.8831 163.388 30.5001C160.975 37.5771 160.608 40.3751 160.213 54.7501L159.765 71.0001H150.732H141.7L142.286 53.2501C142.904 34.5511 144.727 24.3761 148.938 16.1211C151.823 10.4671 151.628 5.90109 148.364 2.63609C145 -0.726907 140.105 -0.887909 136.596 2.25009C133.481 5.03609 128.686 17.0811 126.507 27.5921C125.569 32.1191 124.617 43.0901 124.28 53.2501L123.69 71.0001H115.345H107V38.4231V5.84609L104.077 2.92309C102.082 0.928088 100.152 9.12233e-05 98 9.12233e-05C95.848 9.12233e-05 93.918 0.928088 91.923 2.92309L89 5.84609V38.4231V71.0001H80.655H72.31L71.72 53.2501C71.383 43.0901 70.431 32.1191 69.493 27.5921C67.314 17.0811 62.519 5.03609 59.404 2.25009C55.998 -0.795909 51.059 -0.710905 47.646 2.45209C44.221 5.62609 44.191 9.92109 47.539 17.4911C51.71 26.9241 53.007 34.4791 53.676 53.2501L54.31 71.0001H45.272H36.235L35.787 54.7501C35.392 40.3751 35.025 37.5771 32.612 30.5001C27.194 14.6091 16.228 -0.02891 9.787 0.03009C7.979 0.04709 5.712 0.519093 4.75 1.08009ZM42.687 108.974C33.431 112.591 20.036 125.024 18.408 131.512C17.476 135.223 20.677 140.453 28.253 147.599C37.495 156.319 44.191 159.471 53.5 159.485C59.317 159.494 61.645 158.953 67.274 156.289C77.634 151.385 88.987 139.161 88.996 132.9C89.004 127.304 76.787 114.707 66.745 109.956C59.16 106.368 50.285 106.006 42.687 108.974ZM129.255 109.904C119.151 114.768 106.996 127.33 107.004 132.9C107.013 139.108 118.562 151.475 128.939 156.389C134.338 158.945 136.744 159.496 142.521 159.498C152.526 159.501 160.369 155.502 169.771 145.605C180.444 134.368 180.278 130.975 168.486 119.388C160.043 111.094 152.727 107.595 143 107.201C136.364 106.933 134.78 107.244 129.255 109.904ZM48.5 125.922C46.3 126.969 43.152 128.945 41.505 130.314L38.511 132.802L40.504 135.005C41.601 136.216 44.434 138.342 46.8 139.728C52.577 143.114 57.36 142.466 64.009 137.395L68.978 133.606L66.756 131.24C60.944 125.054 54.357 123.135 48.5 125.922ZM138.386 125.063C136.674 125.571 133.375 127.677 131.057 129.743L126.841 133.5L131.901 137.343C138.65 142.468 143.407 143.124 149.2 139.728C151.566 138.342 154.351 136.269 155.389 135.122C157.684 132.587 156.742 131.097 150.58 127.511C145.438 124.519 142.329 123.895 138.386 125.063ZM91.923 162.923C89.043 165.804 89 166.008 89 176.973C89 184.805 89.435 188.941 90.47 190.941C92.356 194.589 96.918 196.273 101.03 194.84C105.82 193.17 107 189.638 107 176.973C107 166.008 106.957 165.804 104.077 162.923C102.082 160.928 100.152 160 98 160C95.848 160 93.918 160.928 91.923 162.923ZM94.5 232.155C91.026 234.055 90 236.229 90 241.691V247H98H106V242.082C106 235.732 105.37 234.242 101.928 232.463C98.591 230.737 97.197 230.679 94.5 232.155Z\" fill=\"url(#paint0_linear_55_11)\"/>\n<defs><linearGradient id=\"paint0_linear_55_11\" x1=\"98\" y1=\"0.000244141\" x2=\"98\" y2=\"247\" gradientUnits=\"userSpaceOnUse\">\n<stop stop-color=\"#03B79C\"/><stop offset=\"0.504808\" stop-color=\"#4EDAA4\"/><stop offset=\"0.865285\" stop-color=\"#84F3AA\"/>\n</linearGradient></defs></svg>`;\n\nconst CSS = `\n*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}\nbody{font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,sans-serif;\n color:#171717;background:#fff;line-height:1.6;-webkit-font-smoothing:antialiased}\n.container{max-width:1100px;margin:0 auto;padding:24px 20px}\n/* Header */\n.header{display:flex;align-items:center;gap:12px;margin-bottom:8px}\n.header svg{flex-shrink:0}\n.header h1{font-size:22px;font-weight:700;color:#171717}\n.meta{display:flex;flex-wrap:wrap;gap:8px 20px;font-size:13px;color:#6b7280;margin-bottom:20px}\n.meta-item{display:flex;align-items:center;gap:4px}\n.meta-label{font-weight:600;color:#374151}\n.run-id{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;\n background:#f3f4f6;padding:2px 8px;border-radius:4px}\n.ci-badge{display:inline-flex;align-items:center;gap:4px;background:#eff6ff;\n color:#1d4ed8;padding:2px 8px;border-radius:4px;font-size:12px;font-weight:500}\n.merged-badge{background:#fef3c7;color:#92400e;padding:2px 8px;border-radius:4px;\n font-size:12px;font-weight:500}\n/* Summary Cards */\n.summary{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:12px;margin-bottom:28px}\n.summary-card{border-radius:10px;padding:16px;text-align:center;border:1px solid #e5e7eb}\n.summary-card .count{font-size:32px;font-weight:800;line-height:1.1}\n.summary-card .label{font-size:13px;font-weight:500;color:#6b7280;margin-top:2px}\n.card-passed{border-color:#bbf7d0;background:#f0fdf4}.card-passed .count{color:#16a34a}\n.card-failed{border-color:#fecaca;background:#fef2f2}.card-failed .count{color:#dc2626}\n.card-flaky{border-color:#fde68a;background:#fffbeb}.card-flaky .count{color:#d97706}\n.card-skipped{border-color:#e5e7eb;background:#f9fafb}.card-skipped .count{color:#6b7280}\n.card-total{border-color:#c7d2fe;background:#eef2ff}.card-total .count{color:#4f46e5}\n/* Timeline */\n.timeline{display:flex;flex-direction:column;gap:8px}\n.timeline-entry{border:1px solid #e5e7eb;border-radius:10px;overflow:hidden;\n border-left:4px solid #e5e7eb;transition:border-color .15s}\n.timeline-entry:hover{border-color:#d1d5db}\n.timeline-entry--all-passed{border-left-color:#22c55e}\n.timeline-entry--all-passed:hover{border-color:#86efac}\n.timeline-entry--has-failures{border-left-color:#ef4444}\n.timeline-entry--has-failures:hover{border-color:#fca5a5}\n.timeline-header{display:flex;align-items:center;gap:10px;padding:12px 16px;cursor:pointer;\n user-select:none;background:#fafafa;transition:background .15s}\n.timeline-header:hover{background:#f3f4f6}\n.chevron{width:16px;height:16px;flex-shrink:0;transition:transform .2s;color:#9ca3af}\n.timeline-entry.expanded .chevron{transform:rotate(90deg)}\n.timeline-url{font-size:14px;font-weight:600;color:#171717;overflow:hidden;\n text-overflow:ellipsis;white-space:nowrap;max-width:500px;min-width:0}\n.nav-type-badge{font-size:11px;font-weight:600;padding:2px 8px;border-radius:9999px;\n white-space:nowrap;text-transform:uppercase;letter-spacing:.02em;flex-shrink:0}\n.badge-goto{background:#dbeafe;color:#1e40af}\n.badge-navigation{background:#e0e7ff;color:#3730a3}\n.badge-page_load{background:#c7d2fe;color:#312e81}\n.badge-back{background:#cffafe;color:#155e75}\n.badge-forward{background:#a5f3fc;color:#164e63}\n.badge-spa_route{background:#ede9fe;color:#5b21b6}\n.badge-spa_replace{background:#ddd6fe;color:#4c1d95}\n.badge-hash_change{background:#fae8ff;color:#86198f}\n.badge-popstate{background:#f5d0fe;color:#701a75}\n.badge-link_click{background:#fce7f3;color:#9d174d}\n.badge-form_submit{background:#fbcfe8;color:#831843}\n.badge-redirect{background:#ffedd5;color:#9a3412}\n.badge-refresh{background:#e0f2fe;color:#075985}\n.badge-dummy{background:#f3f4f6;color:#6b7280}\n.badge-fallback{background:#e5e7eb;color:#4b5563}\n.badge-manual_record{background:#fef9c3;color:#854d0e}\n.timeline-info{display:flex;align-items:center;gap:8px;font-size:12px;color:#6b7280;\n margin-left:auto;flex-shrink:0;white-space:nowrap}\n.spec-file{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11px;\n color:#6b7280;background:#f3f4f6;padding:1px 6px;border-radius:3px}\n.timeline-content{display:none;padding:0 16px 16px;border-top:1px solid #f3f4f6}\n.timeline-entry.expanded .timeline-content{display:block}\n/* Test Cards */\n.tests-section{margin-top:12px}\n.spec-summary{font-size:12px;color:#6b7280;margin-bottom:8px;display:flex;gap:12px;flex-wrap:wrap}\n.spec-summary span{font-weight:600}\n.spec-passed{color:#16a34a}.spec-failed{color:#dc2626}.spec-flaky{color:#d97706}\n.test-card{padding:8px 0;border-bottom:1px solid #f3f4f6}\n.test-card:last-child{border-bottom:none}\n.test-card-row{display:flex;align-items:flex-start;gap:8px}\n.status-badge{font-size:11px;font-weight:700;padding:2px 8px;border-radius:9999px;\n flex-shrink:0;margin-top:2px;text-transform:uppercase;letter-spacing:.03em}\n.status-passed{background:#d1fae5;color:#065f46}\n.status-failed{background:#fecaca;color:#991b1b}\n.status-flaky{background:#fde68a;color:#92400e}\n.status-skipped{background:#f3f4f6;color:#6b7280}\n.status-timedout{background:#ffedd5;color:#9a3412}\n.type-badge{background:#ede9fe;color:#5b21b6;padding:1px 5px;border-radius:3px;font-size:10px;font-weight:600}\n.flaky-badge{background:#fef3c7;color:#92400e;padding:1px 5px;border-radius:3px;font-size:10px;font-weight:600}\n.file-path{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:10px;color:#6b7280}\n.suite-name{font-size:11px;color:#9ca3af}\n.status-mismatch{font-size:10px;color:#dc2626;font-weight:600}\n.card-timedout{border-color:#ffedd5;background:#fff7ed}.card-timedout .count{color:#ea580c}\n.test-info{flex:1;min-width:0}\n.test-title{font-size:13px;color:#171717;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.test-meta{display:flex;gap:8px;align-items:center;margin-top:2px;font-size:11px;color:#9ca3af}\n.retry-badge{background:#fef3c7;color:#92400e;padding:1px 5px;border-radius:3px;font-size:10px;font-weight:600}\n.tag-badge{background:#eff6ff;color:#1d4ed8;padding:1px 5px;border-radius:3px;font-size:10px}\n.meta-prefix{font-size:10px;color:#6b7280;font-weight:600;text-transform:uppercase;letter-spacing:.04em}\n.test-id{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:10px;\n color:#6b7280;background:#f3f4f6;padding:1px 6px;border-radius:3px}\n.network-panel--has-failures{border-color:#fecaca}\n.network-panel--has-failures .network-header{background:#fef2f2;color:#991b1b}\n.failed-requests-banner{display:flex;align-items:center;gap:6px;padding:8px 12px;\n background:#fef2f2;color:#991b1b;font-size:12px;font-weight:600;border-top:1px solid #fecaca}\n.failed-urls-list{padding:6px 12px;background:#fef2f2;border-top:1px solid #fecaca;font-size:11px;\n font-family:ui-monospace,SFMono-Regular,Menlo,monospace;max-height:200px;overflow-y:auto}\n.failed-url-item{padding:2px 0;color:#991b1b;word-break:break-all}\n.failed-url-status{font-weight:700;margin-right:4px}\n.test-duration{font-size:12px;color:#9ca3af;flex-shrink:0;margin-top:2px}\n/* Failure Details */\n.failure-toggle{font-size:12px;color:#03b79c;cursor:pointer;margin-top:4px;\n border:none;background:none;padding:0;text-decoration:underline;font-family:inherit}\n.failure-toggle:hover{color:#028a75}\n.failure-details{display:none;margin-top:8px;border-radius:8px;overflow:hidden;\n border:1px solid #e5e7eb}\n.failure-details.show{display:block}\n.failure-message{padding:12px;background:#171717;color:#f8f8f8;font-size:12px;\n font-family:ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre-wrap;\n word-break:break-word;line-height:1.5;overflow-x:auto}\n.code-snippet{background:#1e1e1e;padding:0;font-size:12px;\n font-family:ui-monospace,SFMono-Regular,Menlo,monospace;overflow-x:auto}\n.code-line{display:flex;padding:0 12px;line-height:1.7}\n.code-line.highlight{background:rgba(239,68,68,.2)}\n.line-num{color:#6b7280;min-width:40px;text-align:right;padding-right:12px;\n user-select:none;flex-shrink:0}\n.line-code{color:#d4d4d4;white-space:pre;overflow-x:auto}\n.stack-toggle{font-size:11px;color:#6b7280;cursor:pointer;padding:8px 12px;\n border:none;background:#f9fafb;width:100%;text-align:left;font-family:inherit;\n border-top:1px solid #e5e7eb}\n.stack-toggle:hover{background:#f3f4f6;color:#374151}\n.stack-trace{display:none;padding:12px;background:#fafafa;font-size:11px;\n font-family:ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre-wrap;\n word-break:break-word;color:#6b7280;border-top:1px solid #e5e7eb;max-height:300px;overflow-y:auto}\n.stack-trace.show{display:block}\n/* Network Panel */\n.network-panel{margin-top:16px;border:1px solid #e5e7eb;border-radius:8px;overflow:hidden}\n.network-header{font-size:12px;font-weight:600;color:#374151;padding:10px 12px;\n background:#f9fafb;border-bottom:1px solid #e5e7eb;display:flex;align-items:center;gap:6px}\n.network-summary{display:flex;gap:16px;padding:10px 12px;font-size:12px;flex-wrap:wrap}\n.net-stat{display:flex;flex-direction:column;align-items:center;gap:1px}\n.net-stat .val{font-weight:700;font-size:14px;color:#171717}\n.net-stat .lbl{color:#9ca3af;font-size:11px}\n.net-stat.has-failed .val{color:#dc2626}\n.resource-breakdown{display:flex;gap:6px;padding:8px 12px;flex-wrap:wrap;border-top:1px solid #f3f4f6}\n.resource-type{display:flex;align-items:center;gap:4px;font-size:11px;padding:3px 8px;\n border-radius:4px;background:#f3f4f6;color:#374151}\n.resource-type .rt-count{font-weight:700}\n.resource-type--zero{opacity:.45}\n/* Empty State */\n.empty-state{text-align:center;padding:60px 20px;color:#9ca3af}\n.empty-state svg{width:48px;height:48px;margin-bottom:12px;opacity:.4}\n.empty-state p{font-size:15px;font-weight:500}\n/* No-network */\n.no-network{font-size:12px;color:#9ca3af;padding:10px 12px;font-style:italic}\n/* Section title */\n.section-title{font-size:16px;font-weight:700;color:#171717;margin-bottom:12px;\n display:flex;align-items:center;gap:8px}\n.section-title::before{content:'';width:4px;height:18px;background:#03b79c;border-radius:2px}\n/* Artifacts Panel */\n.artifacts-panel{margin-top:10px;padding:10px 12px;background:#f9fafb;border:1px solid #e5e7eb;\n border-radius:8px}\n.artifacts-panel-header{display:flex;align-items:center;gap:6px;font-size:11px;font-weight:600;\n color:#6b7280;text-transform:uppercase;letter-spacing:.04em;margin-bottom:8px}\n.artifacts-row{display:flex;gap:16px;align-items:flex-start;flex-wrap:wrap}\n/* Screenshot */\n.artifact-screenshot-wrap{display:flex;flex-direction:column;gap:4px;flex-shrink:0}\n.artifact-thumbnail{height:140px;width:auto;border-radius:6px;cursor:pointer;\n border:1px solid #e5e7eb;transition:border-color .15s,box-shadow .15s;object-fit:cover;display:block}\n.artifact-thumbnail:hover{border-color:#03b79c;box-shadow:0 0 0 2px rgba(3,183,156,.2)}\n.artifact-label{font-size:10px;color:#9ca3af;text-align:center}\n/* Video */\n.artifact-video-wrap{flex:1;min-width:200px;max-width:480px;display:flex;flex-direction:column;gap:4px}\n.artifact-video-container{border-radius:6px;overflow:hidden;border:1px solid #e5e7eb;display:none}\n.artifact-video-container.show{display:block}\n.artifact-video{width:100%;max-height:320px;display:block;background:#000}\n.video-toggle{font-size:12px;color:#03b79c;cursor:pointer;\n border:none;background:none;padding:0;text-decoration:underline;font-family:inherit}\n.video-toggle:hover{color:#028a75}\n/* Lightbox */\n.lightbox-overlay{position:fixed;inset:0;background:rgba(0,0,0,.85);z-index:1000;\n display:flex;align-items:center;justify-content:center;cursor:zoom-out}\n.lightbox-overlay img{max-width:90vw;max-height:90vh;border-radius:8px;box-shadow:0 4px 24px rgba(0,0,0,.4)}\n.lightbox-close{position:fixed;top:16px;right:16px;z-index:1001;width:36px;height:36px;\n border-radius:50%;border:none;background:rgba(255,255,255,.15);color:#fff;font-size:20px;\n cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .15s}\n.lightbox-close:hover{background:rgba(255,255,255,.3)}\n`;\n\nconst JS = `\n(function(){\n var data=JSON.parse(document.getElementById('report-data').textContent);\n\n function esc(s){if(!s)return '';return s.replace(/&/g,'&amp;').replace(/</g,'&lt;')\n .replace(/>/g,'&gt;').replace(/\"/g,'&quot;').replace(/'/g,'&#39;')}\n function stripAnsi(s){return s?s.replace(/\\\\u001b\\\\[[0-9;]*m/g,'').replace(/\\\\x1b\\\\[[0-9;]*m/g,''):''}\n function fmtDur(ms){if(ms<1000)return Math.round(ms)+'ms';\n if(ms<60000)return (ms/1000).toFixed(1)+'s';\n var m=Math.floor(ms/60000),s=Math.round((ms%60000)/1000);\n return s>0?m+'m '+s+'s':m+'m'}\n function fmtBytes(b){if(b===0)return '0 B';if(b<1024)return b+' B';\n if(b<1048576)return (b/1024).toFixed(1)+' KB';return (b/1048576).toFixed(1)+' MB'}\n function fmtTime(iso){try{return new Date(iso).toLocaleString()}catch(e){return iso}}\n\n var app=document.getElementById('app');\n\n // Header\n var h='<div class=\"header\">__LOGO_SVG__<h1>TestRelic Report</h1></div>';\n h+='<div class=\"meta\">';\n h+='<div class=\"meta-item\"><span class=\"meta-label\">Run ID</span><span class=\"run-id\">'+esc(data.testRunId)+'</span></div>';\n h+='<div class=\"meta-item\"><span class=\"meta-label\">Started</span>'+fmtTime(data.startedAt)+'</div>';\n h+='<div class=\"meta-item\"><span class=\"meta-label\">Completed</span>'+fmtTime(data.completedAt)+'</div>';\n h+='<div class=\"meta-item\"><span class=\"meta-label\">Duration</span>'+fmtDur(data.totalDuration)+'</div>';\n if(data.ci){\n h+='<div class=\"meta-item\"><span class=\"ci-badge\">'+esc(data.ci.provider)+'</span></div>';\n if(data.ci.branch)h+='<div class=\"meta-item\"><span class=\"meta-label\">Branch</span>'+esc(data.ci.branch)+'</div>';\n if(data.ci.commitSha)h+='<div class=\"meta-item\"><span class=\"meta-label\">Commit</span><span class=\"run-id\">'+esc(data.ci.commitSha.substring(0,8))+'</span></div>';\n if(data.ci.buildId)h+='<div class=\"meta-item\"><span class=\"meta-label\">Build</span>'+esc(data.ci.buildId)+'</div>';\n }\n if(data.shardRunIds&&data.shardRunIds.length>0){\n h+='<div class=\"meta-item\"><span class=\"merged-badge\">Merged Report ('+data.shardRunIds.length+' shards)</span></div>';\n }\n h+='</div>';\n\n // Summary\n var s=data.summary;\n h+='<div class=\"summary\">';\n h+='<div class=\"summary-card card-total\"><div class=\"count\">'+s.total+'</div><div class=\"label\">Total</div></div>';\n h+='<div class=\"summary-card card-passed\"><div class=\"count\">'+s.passed+'</div><div class=\"label\">Passed</div></div>';\n h+='<div class=\"summary-card card-failed\"><div class=\"count\">'+s.failed+'</div><div class=\"label\">Failed</div></div>';\n h+='<div class=\"summary-card card-flaky\"><div class=\"count\">'+s.flaky+'</div><div class=\"label\">Flaky</div></div>';\n h+='<div class=\"summary-card card-skipped\"><div class=\"count\">'+s.skipped+'</div><div class=\"label\">Skipped</div></div>';\n if(s.timedout!==undefined){h+='<div class=\"summary-card card-timedout\"><div class=\"count\">'+s.timedout+'</div><div class=\"label\">Timed Out</div></div>';}\n h+='</div>';\n\n // Timeline\n h+='<div class=\"section-title\">Navigation Timeline</div>';\n if(data.timeline.length===0){\n h+='<div class=\"empty-state\">__LOGO_SVG__<p>No test data recorded</p></div>';\n }else{\n h+='<div class=\"timeline\" id=\"timeline\">';\n for(var i=0;i<data.timeline.length;i++){\n var e=data.timeline[i];\n var hasFail=e.tests.some(function(t){return t.status==='failed'});\n var allPassed=!hasFail&&e.tests.length>0&&e.tests.every(function(t){return t.status==='passed'||t.status==='flaky'});\n var cls='timeline-entry'+(hasFail?' timeline-entry--has-failures':'')+(allPassed?' timeline-entry--all-passed':'');\n h+='<div class=\"'+cls+'\" data-idx=\"'+i+'\">';\n h+='<div class=\"timeline-header\" onclick=\"toggleEntry(this)\">';\n h+='<svg class=\"chevron\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M9 18l6-6-6-6\"/></svg>';\n h+='<span class=\"timeline-url\" title=\"'+esc(e.url)+'\">'+esc(e.url)+'</span>';\n h+='<span class=\"nav-type-badge badge-'+e.navigationType+'\">'+esc(e.navigationType.replace(/_/g,' '))+'</span>';\n h+='<div class=\"timeline-info\">';\n h+='<span class=\"spec-file\">'+esc(e.specFile)+'</span>';\n h+='<span>'+fmtTime(e.visitedAt)+'</span>';\n h+='<span>'+fmtDur(e.duration)+'</span>';\n h+='</div></div>';\n h+='<div class=\"timeline-content\">';\n h+=renderTests(e.tests);\n h+=renderNetwork(e.networkStats);\n h+='</div></div>';\n }\n h+='</div>';\n }\n\n app.innerHTML=h;\n\n function renderTests(tests){\n if(!tests||tests.length===0)return '';\n var out='<div class=\"tests-section\">';\n // Spec summary\n var pc=0,fc=0,fkc=0,sc=0,toc=0;\n tests.forEach(function(t){if(t.status==='passed')pc++;else if(t.status==='failed')fc++;else if(t.status==='flaky')fkc++;else if(t.status==='skipped')sc++;else if(t.status==='timedout')toc++});\n out+='<div class=\"spec-summary\">';\n if(pc>0)out+='<span class=\"spec-passed\">'+pc+' passed</span>';\n if(fc>0)out+='<span class=\"spec-failed\">'+fc+' failed</span>';\n if(fkc>0)out+='<span class=\"spec-flaky\">'+fkc+' flaky</span>';\n if(sc>0)out+='<span style=\"color:#6b7280;font-weight:600\">'+sc+' skipped</span>';\n if(toc>0)out+='<span style=\"color:#ea580c;font-weight:600\">'+toc+' timed out</span>';\n out+='</div>';\n for(var j=0;j<tests.length;j++){\n var t=tests[j];\n out+='<div class=\"test-card\">';\n out+='<div class=\"test-card-row\">';\n out+='<span class=\"status-badge status-'+t.status+'\">'+t.status+'</span>';\n out+='<div class=\"test-info\">';\n out+='<div class=\"test-title\" title=\"'+esc(t.title)+'\">'+esc(t.title)+'</div>';\n out+='<div class=\"test-meta\">';\n if(t.testType&&t.testType!=='unknown')out+='<span class=\"type-badge\">'+esc(t.testType)+'</span>';\n if(t.isFlaky)out+='<span class=\"flaky-badge\">flaky</span>';\n if(t.retryCount>0)out+='<span class=\"retry-badge\">'+t.retryCount+' retries</span>';\n if(t.retryStatus)out+='<span class=\"retry-badge\">'+esc(t.retryStatus)+'</span>';\n if(t.tags&&t.tags.length>0){out+='<span class=\"meta-prefix\">Tags:</span>';t.tags.forEach(function(tag){if(tag)out+='<span class=\"tag-badge\">'+esc(tag)+'</span>'});}\n if(t.expectedStatus&&t.actualStatus&&t.expectedStatus!==t.actualStatus)out+='<span class=\"status-mismatch\">expected: '+esc(t.expectedStatus)+' actual: '+esc(t.actualStatus)+'</span>';\n out+='</div>';\n if(t.testId||t.filePath||t.suiteName){out+='<div class=\"test-meta\">';\n if(t.testId)out+='<span class=\"meta-prefix\">ID:</span><span class=\"test-id\" title=\"Full ID: '+esc(t.testId)+'\">'+esc(t.testId.substring(0,12))+'</span>';\n if(t.filePath)out+='<span class=\"meta-prefix\">File:</span><span class=\"file-path\">'+esc(t.filePath)+'</span>';\n if(t.suiteName)out+='<span class=\"meta-prefix\">Suite:</span><span class=\"suite-name\">'+esc(t.suiteName)+'</span>';\n out+='</div>';}\n if((t.status==='failed'||t.status==='flaky')&&t.failure){\n var fid='fail-'+Math.random().toString(36).substr(2,9);\n out+='<button class=\"failure-toggle\" onclick=\"toggleFail(\\\\''+fid+'\\\\')\">Show details</button>';\n out+='<div class=\"failure-details\" id=\"'+fid+'\">';\n out+='<div class=\"failure-message\">'+esc(stripAnsi(t.failure.message))+'</div>';\n if(t.failure.code){\n out+=renderCodeSnippet(t.failure.code,t.failure.line);\n }\n if(t.failure.line!==null){\n out+='<div style=\"padding:4px 12px;font-size:11px;color:#9ca3af;background:#f9fafb\">Line '+t.failure.line+'</div>';\n }\n if(t.failure.stack){\n var sid='stack-'+Math.random().toString(36).substr(2,9);\n out+='<button class=\"stack-toggle\" onclick=\"toggleStack(\\\\''+sid+'\\\\')\">Show stack trace</button>';\n out+='<div class=\"stack-trace\" id=\"'+sid+'\">'+esc(stripAnsi(t.failure.stack))+'</div>';\n }\n out+='</div>';\n } else if(t.status==='failed'&&!t.failure){\n out+='<div style=\"margin-top:4px;font-size:12px;color:#9ca3af;font-style:italic\">No diagnostic information available</div>';\n }\n out+='</div>';\n out+='<span class=\"test-duration\">'+fmtDur(t.duration)+'</span>';\n out+='</div>';\n if(t.artifacts&&(t.artifacts.screenshot||t.artifacts.video)){\n out+='<div class=\"artifacts-panel\">';\n out+='<div class=\"artifacts-panel-header\"><svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\"/><circle cx=\"8.5\" cy=\"8.5\" r=\"1.5\"/><path d=\"M21 15l-5-5L5 21\"/></svg>Artifacts</div>';\n out+='<div class=\"artifacts-row\">';\n if(t.artifacts.screenshot){\n out+='<div class=\"artifact-screenshot-wrap\">';\n out+='<img class=\"artifact-thumbnail\" src=\"'+esc(t.artifacts.screenshot)+'\" loading=\"lazy\" alt=\"Screenshot\" onclick=\"openLightbox(this.src)\">';\n out+='<span class=\"artifact-label\">Click to enlarge</span>';\n out+='</div>';\n }\n if(t.artifacts.video){\n var vid='video-'+Math.random().toString(36).substr(2,9);\n out+='<div class=\"artifact-video-wrap\">';\n out+='<button class=\"video-toggle\" onclick=\"toggleVideo(\\\\''+vid+'\\\\')\">Show video</button>';\n out+='<div class=\"artifact-video-container\" id=\"'+vid+'\"><video class=\"artifact-video\" controls preload=\"none\" src=\"'+esc(t.artifacts.video)+'\"></video></div>';\n out+='</div>';\n }\n out+='</div></div>';\n }\n out+='</div>';\n }\n out+='</div>';\n return out;\n }\n\n function renderCodeSnippet(code,failLine){\n var lines=code.split('\\\\n');\n var out='<div class=\"code-snippet\">';\n for(var k=0;k<lines.length;k++){\n var raw=lines[k];\n var numMatch=raw.match(/^\\\\s*(>?\\\\s*)(\\\\d+)\\\\s*\\\\|/);\n var lineNum=numMatch?numMatch[2]:'';\n var isHighlight=raw.trimStart().startsWith('>');\n var codePart=raw.replace(/^\\\\s*>?\\\\s*\\\\d+\\\\s*\\\\|/,'');\n out+='<div class=\"code-line'+(isHighlight?' highlight':'')+'\">';\n out+='<span class=\"line-num\">'+esc(lineNum)+'</span>';\n out+='<span class=\"line-code\">'+esc(codePart)+'</span>';\n out+='</div>';\n }\n out+='</div>';\n return out;\n }\n\n function renderNetwork(stats){\n if(!stats)return '<div class=\"no-network\">No network data captured</div>';\n var hasFailedReqs=stats.failedRequests>0;\n var out='<div class=\"network-panel'+(hasFailedReqs?' network-panel--has-failures':'')+'\">';\n out+='<div class=\"network-header\"><svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M22 12h-4l-3 9L9 3l-3 9H2\"/></svg>Network</div>';\n out+='<div class=\"network-summary\">';\n out+='<div class=\"net-stat\"><span class=\"val\">'+stats.totalRequests+'</span><span class=\"lbl\">Requests</span></div>';\n out+='<div class=\"net-stat'+(hasFailedReqs?' has-failed':'')+'\"><span class=\"val\">'+stats.failedRequests+'</span><span class=\"lbl\">Failed</span></div>';\n out+='<div class=\"net-stat\"><span class=\"val\">'+fmtBytes(stats.totalBytes)+'</span><span class=\"lbl\">Transferred</span></div>';\n out+='</div>';\n if(hasFailedReqs){out+='<div class=\"failed-requests-banner\"><svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M12 9v2m0 4h.01M10.29 3.86l-8.58 14.6A2 2 0 003.44 21h17.12a2 2 0 001.73-2.54l-8.58-14.6a2 2 0 00-3.42 0z\"/></svg>'+stats.failedRequests+' network request'+(stats.failedRequests>1?'s':'')+' failed</div>';\n if(stats.failedRequestUrls&&stats.failedRequestUrls.length>0){out+='<div class=\"failed-urls-list\">';for(var fi=0;fi<stats.failedRequestUrls.length;fi++){var furl=stats.failedRequestUrls[fi];var spIdx=furl.indexOf(' ');var fStatus=spIdx>0?furl.substring(0,spIdx):'';var fPath=spIdx>0?furl.substring(spIdx+1):furl;out+='<div class=\"failed-url-item\"><span class=\"failed-url-status\">'+esc(fStatus)+'</span>'+esc(fPath)+'</div>';}out+='</div>';}\n }\n if(stats.byType){\n var types=[['XHR','xhr'],['Document','document'],['Script','script'],['Stylesheet','stylesheet'],['Image','image'],['Font','font'],['Other','other']];\n out+='<div class=\"resource-breakdown\">';\n for(var ti=0;ti<types.length;ti++){\n var cnt=stats.byType[types[ti][1]]||0;\n out+='<div class=\"resource-type'+(cnt===0?' resource-type--zero':'')+'\"><span class=\"rt-count\">'+cnt+'</span> '+types[ti][0]+'</div>';\n }\n out+='</div>';\n }\n out+='</div>';\n return out;\n }\n\n})();\n\nfunction toggleEntry(el){el.closest('.timeline-entry').classList.toggle('expanded')}\nfunction toggleFail(id){document.getElementById(id).classList.toggle('show')}\nfunction toggleStack(id){document.getElementById(id).classList.toggle('show')}\nfunction openLightbox(src){var o=document.createElement('div');o.className='lightbox-overlay';\n o.onclick=function(){closeLightbox()};o.innerHTML='<img src=\"'+src.replace(/\"/g,'&quot;')+'\" alt=\"Screenshot\">';\n var b=document.createElement('button');b.className='lightbox-close';b.innerHTML='&times;';\n b.onclick=function(e){e.stopPropagation();closeLightbox()};\n document.body.appendChild(o);document.body.appendChild(b);\n document.addEventListener('keydown',lightboxEsc)}\nfunction closeLightbox(){var o=document.querySelector('.lightbox-overlay');if(o)o.remove();\n var b=document.querySelector('.lightbox-close');if(b)b.remove();\n document.removeEventListener('keydown',lightboxEsc)}\nfunction lightboxEsc(e){if(e.key==='Escape')closeLightbox()}\nfunction toggleVideo(id){var el=document.getElementById(id);if(!el)return;\n var isShown=el.classList.toggle('show');\n var btn=el.previousElementSibling;\n if(btn)btn.textContent=isShown?'Hide video':'Show video';\n if(!isShown){var v=el.querySelector('video');if(v)v.pause()}}\n`;\n\nexport function renderHtmlDocument(reportJson: string): string {\n // Replace placeholder with actual SVG in the JS string\n const jsWithLogo = JS.replace(/__LOGO_SVG__/g, LOGO_SVG.replace(/'/g, \"\\\\'\").replace(/\\n/g, ''));\n\n return `<!-- TestRelic Report — self-contained, no external dependencies -->\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n<meta http-equiv=\"Content-Security-Policy\" content=\"default-src 'none'; style-src 'unsafe-inline'; script-src 'unsafe-inline'; img-src data: blob: 'self'; media-src blob: 'self';\">\n<title>TestRelic Report</title>\n<style>${CSS}</style>\n</head>\n<body>\n<div class=\"container\" id=\"app\"></div>\n<script id=\"report-data\" type=\"application/json\">${reportJson}</script>\n<script>${jsWithLogo}</script>\n</body>\n</html>`;\n}\n","/**\n * Cross-platform browser auto-open utility.\n *\n * Opens a file in the user's default browser.\n * Fire-and-forget — never throws, errors logged to stderr.\n */\n\nimport { exec } from 'node:child_process';\n\nexport function openInBrowser(filePath: string): void {\n try {\n const platform = process.platform;\n let command: string;\n\n if (platform === 'darwin') {\n command = `open \"${filePath}\"`;\n } else if (platform === 'win32') {\n command = `start \"\" \"${filePath}\"`;\n } else {\n command = `xdg-open \"${filePath}\"`;\n }\n\n exec(command, (err) => {\n if (err) {\n process.stderr.write(\n `[testrelic] Failed to open browser: ${err.message}\\n`,\n );\n }\n });\n } catch {\n // Never crash the reporter\n }\n}\n","/**\n * ArtifactManager — copies test artifacts to structured output folders.\n *\n * Handles screenshot/video files from Playwright's result.attachments,\n * organizing them into per-test folders with sanitized names.\n */\n\nimport { mkdirSync, copyFileSync, existsSync } from 'node:fs';\nimport { join, extname } from 'node:path';\nimport type { TestArtifacts } from '@testrelic/core';\n\ninterface Attachment {\n name: string;\n contentType: string;\n path?: string;\n body?: Buffer;\n}\n\n/**\n * Sanitize a test title into a filesystem-safe folder name.\n *\n * Rules:\n * 1. Replace characters not in [a-zA-Z0-9-_ ] with hyphens\n * 2. Replace spaces with hyphens\n * 3. Collapse consecutive hyphens\n * 4. Trim leading/trailing hyphens\n * 5. Truncate to 100 characters\n */\nexport function sanitizeFolderName(title: string): string {\n let name = title\n .replace(/[^a-zA-Z0-9\\-_ ]/g, '-')\n .replace(/\\s+/g, '-')\n .replace(/-{2,}/g, '-')\n .replace(/^-+|-+$/g, '');\n\n if (name.length > 100) {\n name = name.substring(0, 100).replace(/-+$/, '');\n }\n\n return name || 'unnamed-test';\n}\n\n/**\n * Copy test artifacts from Playwright's temp locations to structured output folders.\n *\n * @returns TestArtifacts with relative paths, or null if no artifacts found.\n */\nexport function copyArtifacts(\n attachments: readonly Attachment[],\n testTitle: string,\n retryCount: number,\n outputDir: string,\n): TestArtifacts | null {\n const screenshot = attachments.find(\n (a) => a.name === 'screenshot' && a.path,\n );\n const video = attachments.find(\n (a) => a.name === 'video' && a.path,\n );\n\n if (!screenshot && !video) {\n return null;\n }\n\n let folderName = sanitizeFolderName(testTitle);\n if (retryCount > 0) {\n folderName += `--retry-${retryCount}`;\n }\n\n const artifactDir = join(outputDir, 'artifacts', folderName);\n const result: { screenshot?: string; video?: string } = {};\n\n try {\n mkdirSync(artifactDir, { recursive: true });\n } catch {\n // Cannot create directory — skip artifact capture\n return null;\n }\n\n if (screenshot?.path) {\n try {\n if (existsSync(screenshot.path)) {\n const ext = extname(screenshot.path) || '.png';\n const destName = `screenshot${ext}`;\n copyFileSync(screenshot.path, join(artifactDir, destName));\n result.screenshot = `artifacts/${folderName}/${destName}`;\n }\n } catch {\n // FR-026: never crash — skip this artifact\n }\n }\n\n if (video?.path) {\n try {\n if (existsSync(video.path)) {\n const ext = extname(video.path) || '.webm';\n const destName = `video${ext}`;\n copyFileSync(video.path, join(artifactDir, destName));\n result.video = `artifacts/${folderName}/${destName}`;\n }\n } catch {\n // FR-026: never crash — skip this artifact\n }\n }\n\n if (!result.screenshot && !result.video) {\n return null;\n }\n\n return result;\n}\n","/**\n * @testrelic/playwright-analytics — Main entry point\n *\n * Default export: TestRelicReporter class\n * Named export: recordNavigation helper\n */\n\nexport { default } from './reporter.js';\n\nexport type {\n NavigationType,\n TestRunReport,\n Summary,\n CIMetadata,\n TimelineEntry,\n TestResult,\n FailureDiagnostic,\n NetworkStats,\n ReporterConfig,\n} from './types.js';\n\nexport { SCHEMA_VERSION } from './schema.js';\n\nimport type { NavigationType, NavigationAnnotation } from '@testrelic/core';\n\nlet warned = false;\n\n/**\n * Records a manual navigation event in the current test's annotations.\n * Use for navigation the auto-tracker cannot detect (iframes, web workers).\n *\n * Requires access to the current test info. If not available, logs a\n * warning once and no-ops.\n */\nexport function recordNavigation(\n testInfo: { annotations: Array<{ type: string; description?: string }> } | null | undefined,\n url: string,\n navigationType: NavigationType = 'manual_record',\n): void {\n if (!testInfo || !testInfo.annotations) {\n if (!warned) {\n warned = true;\n process.stderr.write('[testrelic] recordNavigation: reporter not active, navigation not recorded\\n');\n }\n return;\n }\n\n const annotation: NavigationAnnotation = {\n url,\n navigationType,\n timestamp: new Date().toISOString(),\n };\n\n testInfo.annotations.push({\n type: 'lambdatest-nav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iBAAiC,iBAC3B;AACN,MAAI,CAAC,YAAY,CAAC,SAAS,aAAa;AACtC,QAAI,CAAC,QAAQ;AACX,eAAS;AACT,cAAQ,OAAO,MAAM,8EAA8E;AAAA,IACrG;AACA;AAAA,EACF;AAEA,QAAM,aAAmC;AAAA,IACvC;AAAA,IACA;AAAA,IACA,YAAW,oBAAI,KAAK,GAAE,YAAY;AAAA,EACpC;AAEA,WAAS,YAAY,KAAK;AAAA,IACxB,MAAM;AAAA,IACN,aAAa,KAAK,UAAU,UAAU;AAAA,EACxC,CAAC;AACH;","names":["mkdirSync","writeFileSync","renameSync","dirname","mkdirSync","dirname","mkdirSync","writeFileSync","renameSync"]}
package/dist/merge.cjs CHANGED
@@ -99,14 +99,16 @@ function recalculateSummary(reports) {
99
99
  let failed = 0;
100
100
  let flaky = 0;
101
101
  let skipped = 0;
102
+ let timedout = 0;
102
103
  for (const report of reports) {
103
104
  total += report.summary.total;
104
105
  passed += report.summary.passed;
105
106
  failed += report.summary.failed;
106
107
  flaky += report.summary.flaky;
107
108
  skipped += report.summary.skipped;
109
+ timedout += report.summary.timedout ?? 0;
108
110
  }
109
- return { total, passed, failed, flaky, skipped };
111
+ return { total, passed, failed, flaky, skipped, timedout };
110
112
  }
111
113
  // Annotate the CommonJS export names for ESM import in node:
112
114
  0 && (module.exports = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/merge.ts"],"sourcesContent":["/**\n * @testrelic/playwright-analytics/merge\n *\n * Merges multiple shard report files into a single unified timeline.\n * Tree-shakeable: separate entry point from the main reporter.\n */\n\nimport { randomUUID } from 'node:crypto';\nimport { readFileSync, writeFileSync, mkdirSync } from 'node:fs';\nimport { dirname } from 'node:path';\nimport type {\n TestRunReport,\n MergeOptions,\n Summary,\n TimelineEntry,\n} from '@testrelic/core';\nimport { isValidTestRunReport, createError, ErrorCode } from '@testrelic/core';\n\nexport async function mergeReports(\n files: string[],\n options: MergeOptions,\n): Promise<TestRunReport> {\n const reports: TestRunReport[] = [];\n\n for (const file of files) {\n let raw: string;\n try {\n raw = readFileSync(file, 'utf-8');\n } catch (err) {\n throw createError(\n ErrorCode.MERGE_READ_FAILED,\n `Failed to read file: ${file}`,\n err,\n );\n }\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch (err) {\n throw createError(\n ErrorCode.MERGE_INVALID_SCHEMA,\n `Invalid JSON in file: ${file}`,\n err,\n );\n }\n\n if (!isValidTestRunReport(parsed)) {\n throw createError(\n ErrorCode.MERGE_INVALID_SCHEMA,\n `Invalid report schema in file: ${file}`,\n );\n }\n\n reports.push(parsed);\n }\n\n // Collect shard IDs\n const shardRunIds = reports.map((r) => r.testRunId);\n\n // Merge timelines chronologically\n const allTimelines: TimelineEntry[] = [];\n for (const report of reports) {\n allTimelines.push(...report.timeline);\n }\n allTimelines.sort((a, b) =>\n new Date(a.visitedAt).getTime() - new Date(b.visitedAt).getTime(),\n );\n\n // Recalculate summary across all shards\n const summary = recalculateSummary(reports);\n\n // Compute timing\n const startedAt = reports.reduce(\n (earliest, r) => (r.startedAt < earliest ? r.startedAt : earliest),\n reports[0]?.startedAt ?? new Date().toISOString(),\n );\n const completedAt = reports.reduce(\n (latest, r) => (r.completedAt > latest ? r.completedAt : latest),\n reports[0]?.completedAt ?? new Date().toISOString(),\n );\n const totalDuration = new Date(completedAt).getTime() - new Date(startedAt).getTime();\n\n const merged: TestRunReport = {\n schemaVersion: reports[0]?.schemaVersion ?? '1.0.0',\n testRunId: options.testRunId ?? randomUUID(),\n startedAt,\n completedAt,\n totalDuration,\n summary,\n ci: reports.find((r) => r.ci !== null)?.ci ?? null,\n metadata: reports.find((r) => r.metadata !== null)?.metadata ?? null,\n timeline: allTimelines,\n shardRunIds,\n };\n\n // Write to disk\n const dir = dirname(options.output);\n mkdirSync(dir, { recursive: true });\n writeFileSync(options.output, JSON.stringify(merged, null, 2), 'utf-8');\n\n return merged;\n}\n\nfunction recalculateSummary(reports: TestRunReport[]): Summary {\n let total = 0;\n let passed = 0;\n let failed = 0;\n let flaky = 0;\n let skipped = 0;\n\n for (const report of reports) {\n total += report.summary.total;\n passed += report.summary.passed;\n failed += report.summary.failed;\n flaky += report.summary.flaky;\n skipped += report.summary.skipped;\n }\n\n return { total, passed, failed, flaky, skipped };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,yBAA2B;AAC3B,qBAAuD;AACvD,uBAAwB;AAOxB,kBAA6D;AAE7D,eAAsB,aACpB,OACA,SACwB;AACxB,QAAM,UAA2B,CAAC;AAElC,aAAW,QAAQ,OAAO;AACxB,QAAI;AACJ,QAAI;AACF,gBAAM,6BAAa,MAAM,OAAO;AAAA,IAClC,SAAS,KAAK;AACZ,gBAAM;AAAA,QACJ,sBAAU;AAAA,QACV,wBAAwB,IAAI;AAAA,QAC5B;AAAA,MACF;AAAA,IACF;AAEA,QAAI;AACJ,QAAI;AACF,eAAS,KAAK,MAAM,GAAG;AAAA,IACzB,SAAS,KAAK;AACZ,gBAAM;AAAA,QACJ,sBAAU;AAAA,QACV,yBAAyB,IAAI;AAAA,QAC7B;AAAA,MACF;AAAA,IACF;AAEA,QAAI,KAAC,kCAAqB,MAAM,GAAG;AACjC,gBAAM;AAAA,QACJ,sBAAU;AAAA,QACV,kCAAkC,IAAI;AAAA,MACxC;AAAA,IACF;AAEA,YAAQ,KAAK,MAAM;AAAA,EACrB;AAGA,QAAM,cAAc,QAAQ,IAAI,CAAC,MAAM,EAAE,SAAS;AAGlD,QAAM,eAAgC,CAAC;AACvC,aAAW,UAAU,SAAS;AAC5B,iBAAa,KAAK,GAAG,OAAO,QAAQ;AAAA,EACtC;AACA,eAAa;AAAA,IAAK,CAAC,GAAG,MACpB,IAAI,KAAK,EAAE,SAAS,EAAE,QAAQ,IAAI,IAAI,KAAK,EAAE,SAAS,EAAE,QAAQ;AAAA,EAClE;AAGA,QAAM,UAAU,mBAAmB,OAAO;AAG1C,QAAM,YAAY,QAAQ;AAAA,IACxB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[]}
1
+ {"version":3,"sources":["../src/merge.ts"],"sourcesContent":["/**\n * @testrelic/playwright-analytics/merge\n *\n * Merges multiple shard report files into a single unified timeline.\n * Tree-shakeable: separate entry point from the main reporter.\n */\n\nimport { randomUUID } from 'node:crypto';\nimport { readFileSync, writeFileSync, mkdirSync } from 'node:fs';\nimport { dirname } from 'node:path';\nimport type {\n TestRunReport,\n MergeOptions,\n Summary,\n TimelineEntry,\n} from '@testrelic/core';\nimport { isValidTestRunReport, createError, ErrorCode } from '@testrelic/core';\n\nexport async function mergeReports(\n files: string[],\n options: MergeOptions,\n): Promise<TestRunReport> {\n const reports: TestRunReport[] = [];\n\n for (const file of files) {\n let raw: string;\n try {\n raw = readFileSync(file, 'utf-8');\n } catch (err) {\n throw createError(\n ErrorCode.MERGE_READ_FAILED,\n `Failed to read file: ${file}`,\n err,\n );\n }\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch (err) {\n throw createError(\n ErrorCode.MERGE_INVALID_SCHEMA,\n `Invalid JSON in file: ${file}`,\n err,\n );\n }\n\n if (!isValidTestRunReport(parsed)) {\n throw createError(\n ErrorCode.MERGE_INVALID_SCHEMA,\n `Invalid report schema in file: ${file}`,\n );\n }\n\n reports.push(parsed);\n }\n\n // Collect shard IDs\n const shardRunIds = reports.map((r) => r.testRunId);\n\n // Merge timelines chronologically\n const allTimelines: TimelineEntry[] = [];\n for (const report of reports) {\n allTimelines.push(...report.timeline);\n }\n allTimelines.sort((a, b) =>\n new Date(a.visitedAt).getTime() - new Date(b.visitedAt).getTime(),\n );\n\n // Recalculate summary across all shards\n const summary = recalculateSummary(reports);\n\n // Compute timing\n const startedAt = reports.reduce(\n (earliest, r) => (r.startedAt < earliest ? r.startedAt : earliest),\n reports[0]?.startedAt ?? new Date().toISOString(),\n );\n const completedAt = reports.reduce(\n (latest, r) => (r.completedAt > latest ? r.completedAt : latest),\n reports[0]?.completedAt ?? new Date().toISOString(),\n );\n const totalDuration = new Date(completedAt).getTime() - new Date(startedAt).getTime();\n\n const merged: TestRunReport = {\n schemaVersion: reports[0]?.schemaVersion ?? '1.0.0',\n testRunId: options.testRunId ?? randomUUID(),\n startedAt,\n completedAt,\n totalDuration,\n summary,\n ci: reports.find((r) => r.ci !== null)?.ci ?? null,\n metadata: reports.find((r) => r.metadata !== null)?.metadata ?? null,\n timeline: allTimelines,\n shardRunIds,\n };\n\n // Write to disk\n const dir = dirname(options.output);\n mkdirSync(dir, { recursive: true });\n writeFileSync(options.output, JSON.stringify(merged, null, 2), 'utf-8');\n\n return merged;\n}\n\nfunction recalculateSummary(reports: TestRunReport[]): Summary {\n let total = 0;\n let passed = 0;\n let failed = 0;\n let flaky = 0;\n let skipped = 0;\n let timedout = 0;\n\n for (const report of reports) {\n total += report.summary.total;\n passed += report.summary.passed;\n failed += report.summary.failed;\n flaky += report.summary.flaky;\n skipped += report.summary.skipped;\n timedout += report.summary.timedout ?? 0;\n }\n\n return { total, passed, failed, flaky, skipped, timedout };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,yBAA2B;AAC3B,qBAAuD;AACvD,uBAAwB;AAOxB,kBAA6D;AAE7D,eAAsB,aACpB,OACA,SACwB;AACxB,QAAM,UAA2B,CAAC;AAElC,aAAW,QAAQ,OAAO;AACxB,QAAI;AACJ,QAAI;AACF,gBAAM,6BAAa,MAAM,OAAO;AAAA,IAClC,SAAS,KAAK;AACZ,gBAAM;AAAA,QACJ,sBAAU;AAAA,QACV,wBAAwB,IAAI;AAAA,QAC5B;AAAA,MACF;AAAA,IACF;AAEA,QAAI;AACJ,QAAI;AACF,eAAS,KAAK,MAAM,GAAG;AAAA,IACzB,SAAS,KAAK;AACZ,gBAAM;AAAA,QACJ,sBAAU;AAAA,QACV,yBAAyB,IAAI;AAAA,QAC7B;AAAA,MACF;AAAA,IACF;AAEA,QAAI,KAAC,kCAAqB,MAAM,GAAG;AACjC,gBAAM;AAAA,QACJ,sBAAU;AAA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K,CAAC;AAClC,oCAAc,QAAQ,QAAQ,KAAK,UAAU,QAAQ,MAAM,CAAC,GAAG,OAAO;AAEtE,SAAO;AACT;AAEA,SAAS,mBAAmB,SAAmC;AAC7D,MAAI,QAAQ;AACZ,MAAI,SAAS;AACb,MAAI,SAAS;AACb,MAAI,QAAQ;AACZ,MAAI,UAAU;AACd,MAAI,WAAW;AAEf,aAAW,UAAU,SAAS;AAC5B,aAAS,OAAO,QAAQ;AACxB,cAAU,OAAO,QAAQ;AACzB,cAAU,OAAO,QAAQ;AACzB,aAAS,OAAO,QAAQ;AACxB,eAAW,OAAO,QAAQ;AAC1B,gBAAY,OAAO,QAAQ,YAAY;AAAA,EACzC;AAEA,SAAO,EAAE,OAAO,QAAQ,QAAQ,OAAO,SAAS,SAAS;AAC3D;","names":[]}
package/dist/merge.js CHANGED
@@ -75,14 +75,16 @@ function recalculateSummary(reports) {
75
75
  let failed = 0;
76
76
  let flaky = 0;
77
77
  let skipped = 0;
78
+ let timedout = 0;
78
79
  for (const report of reports) {
79
80
  total += report.summary.total;
80
81
  passed += report.summary.passed;
81
82
  failed += report.summary.failed;
82
83
  flaky += report.summary.flaky;
83
84
  skipped += report.summary.skipped;
85
+ timedout += report.summary.timedout ?? 0;
84
86
  }
85
- return { total, passed, failed, flaky, skipped };
87
+ return { total, passed, failed, flaky, skipped, timedout };
86
88
  }
87
89
  export {
88
90
  mergeReports
package/dist/merge.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/merge.ts"],"sourcesContent":["/**\n * @testrelic/playwright-analytics/merge\n *\n * Merges multiple shard report files into a single unified timeline.\n * Tree-shakeable: separate entry point from the main reporter.\n */\n\nimport { randomUUID } from 'node:crypto';\nimport { readFileSync, writeFileSync, mkdirSync } from 'node:fs';\nimport { dirname } from 'node:path';\nimport type {\n TestRunReport,\n MergeOptions,\n Summary,\n TimelineEntry,\n} from '@testrelic/core';\nimport { isValidTestRunReport, createError, ErrorCode } from '@testrelic/core';\n\nexport async function mergeReports(\n files: string[],\n options: MergeOptions,\n): Promise<TestRunReport> {\n const reports: TestRunReport[] = [];\n\n for (const file of files) {\n let raw: string;\n try {\n raw = readFileSync(file, 'utf-8');\n } catch (err) {\n throw createError(\n ErrorCode.MERGE_READ_FAILED,\n `Failed to read file: ${file}`,\n err,\n );\n }\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch (err) {\n throw createError(\n ErrorCode.MERGE_INVALID_SCHEMA,\n `Invalid JSON in file: ${file}`,\n err,\n );\n }\n\n if (!isValidTestRunReport(parsed)) {\n throw createError(\n ErrorCode.MERGE_INVALID_SCHEMA,\n `Invalid report schema in file: ${file}`,\n );\n }\n\n reports.push(parsed);\n }\n\n // Collect shard IDs\n const shardRunIds = reports.map((r) => r.testRunId);\n\n // Merge timelines chronologically\n const allTimelines: TimelineEntry[] = [];\n for (const report of reports) {\n allTimelines.push(...report.timeline);\n }\n allTimelines.sort((a, b) =>\n new Date(a.visitedAt).getTime() - new Date(b.visitedAt).getTime(),\n );\n\n // Recalculate summary across all shards\n const summary = recalculateSummary(reports);\n\n // Compute timing\n const startedAt = reports.reduce(\n (earliest, r) => (r.startedAt < earliest ? r.startedAt : earliest),\n reports[0]?.startedAt ?? new Date().toISOString(),\n );\n const completedAt = reports.reduce(\n (latest, r) => (r.completedAt > latest ? r.completedAt : latest),\n reports[0]?.completedAt ?? new Date().toISOString(),\n );\n const totalDuration = new Date(completedAt).getTime() - new Date(startedAt).getTime();\n\n const merged: TestRunReport = {\n schemaVersion: reports[0]?.schemaVersion ?? '1.0.0',\n testRunId: options.testRunId ?? randomUUID(),\n startedAt,\n completedAt,\n totalDuration,\n summary,\n ci: reports.find((r) => r.ci !== null)?.ci ?? null,\n metadata: reports.find((r) => r.metadata !== null)?.metadata ?? null,\n timeline: allTimelines,\n shardRunIds,\n };\n\n // Write to disk\n const dir = dirname(options.output);\n mkdirSync(dir, { recursive: true });\n writeFileSync(options.output, JSON.stringify(merged, null, 2), 'utf-8');\n\n return merged;\n}\n\nfunction recalculateSummary(reports: TestRunReport[]): Summary {\n let total = 0;\n let passed = 0;\n let failed = 0;\n let flaky = 0;\n let skipped = 0;\n\n for (const report of reports) {\n total += report.summary.total;\n passed += report.summary.passed;\n failed += report.summary.failed;\n flaky += report.summary.flaky;\n skipped += report.summary.skipped;\n }\n\n return { total, passed, failed, flaky, skipped };\n}\n"],"mappings":";AAOA,SAAS,kBAAkB;AAC3B,SAAS,cAAc,eAAe,iBAAiB;AACvD,SAAS,eAAe;AAOxB,SAAS,sBAAsB,aAAa,iBAAiB;AAE7D,eAAsB,aACpB,OACA,SACwB;AACxB,QAAM,UAA2B,CAAC;AAElC,aAAW,QAAQ,OAAO;AACxB,QAAI;AACJ,QAAI;AACF,YAAM,aAAa,MAAM,OAAO;AAAA,IAClC,SAAS,KAAK;AACZ,YAAM;AAAA,QACJ,UAAU;AAAA,QACV,wBAAwB,IAAI;AAAA,QAC5B;AAAA,MACF;AAAA,IACF;AAEA,QAAI;AACJ,QAAI;AACF,eAAS,KAAK,MAAM,GAAG;AAAA,IACzB,SAAS,KAAK;AACZ,YAAM;AAAA,QACJ,UAAU;AAAA,QACV,yBAAyB,IAAI;AAAA,QAC7B;AAAA,MACF;AAAA,IACF;AAEA,QAAI,CAAC,qBAAqB,MAAM,GAAG;AACjC,YAAM;AAAA,QACJ,UAAU;AAAA,QACV,kCAAkC,IAAI;AAAA,MACxC;AAAA,IACF;AAEA,YAAQ,KAAK,MAAM;AAAA,EACrB;AAGA,QAAM,cAAc,QAAQ,IAAI,CAAC,MAAM,EAAE,SAAS;AAGlD,QAAM,eAAgC,CAAC;AACvC,aAAW,UAAU,SAAS;AAC5B,iBAAa,KAAK,GAAG,OAAO,QAAQ;AAAA,EACtC;AACA,eAAa;AAAA,IAAK,CAAC,GAAG,MACpB,IAAI,KAAK,EAAE,SAAS,EAAE,QAAQ,IAAI,IAAI,KAAK,EAAE,SAAS,EAAE,QAAQ;AAAA,EAClE;AAGA,QAAM,UA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,EAAE,OAAO,QAAQ,QAAQ,OAAO,QAAQ;AACjD;","names":[]}
1
+ {"version":3,"sources":["../src/merge.ts"],"sourcesContent":["/**\n * @testrelic/playwright-analytics/merge\n *\n * Merges multiple shard report files into a single unified timeline.\n * Tree-shakeable: separate entry point from the main reporter.\n */\n\nimport { randomUUID } from 'node:crypto';\nimport { readFileSync, writeFileSync, mkdirSync } from 'node:fs';\nimport { dirname } from 'node:path';\nimport type {\n TestRunReport,\n MergeOptions,\n Summary,\n TimelineEntry,\n} from '@testrelic/core';\nimport { isValidTestRunReport, createError, ErrorCode } from '@testrelic/core';\n\nexport async function mergeReports(\n files: string[],\n options: MergeOptions,\n): Promise<TestRunReport> {\n const reports: TestRunReport[] = [];\n\n for (const file of files) {\n let raw: string;\n try {\n raw = readFileSync(file, 'utf-8');\n } catch (err) {\n throw createError(\n ErrorCode.MERGE_READ_FAILED,\n `Failed to read file: ${file}`,\n err,\n );\n }\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch (err) {\n throw createError(\n ErrorCode.MERGE_INVALID_SCHEMA,\n `Invalid JSON in file: ${file}`,\n err,\n );\n }\n\n if (!isValidTestRunReport(parsed)) {\n throw createError(\n ErrorCode.MERGE_INVALID_SCHEMA,\n `Invalid report schema in file: ${file}`,\n );\n }\n\n reports.push(parsed);\n }\n\n // Collect shard IDs\n const shardRunIds = reports.map((r) => r.testRunId);\n\n // Merge timelines chronologically\n const allTimelines: TimelineEntry[] = [];\n for (const report of reports) {\n allTimelines.push(...report.timeline);\n }\n allTimelines.sort((a, b) =>\n new Date(a.visitedAt).getTime() - new Date(b.visitedAt).getTime(),\n );\n\n // Recalculate summary across all shards\n const summary = recalculateSummary(reports);\n\n // Compute timing\n const startedAt = reports.reduce(\n (earliest, r) => (r.startedAt < earliest ? r.startedAt : earliest),\n reports[0]?.startedAt ?? new Date().toISOString(),\n );\n const completedAt = reports.reduce(\n (latest, r) => (r.completedAt > latest ? r.completedAt : latest),\n reports[0]?.completedAt ?? new Date().toISOString(),\n );\n const totalDuration = new Date(completedAt).getTime() - new Date(startedAt).getTime();\n\n const merged: TestRunReport = {\n schemaVersion: reports[0]?.schemaVersion ?? '1.0.0',\n testRunId: options.testRunId ?? randomUUID(),\n startedAt,\n completedAt,\n totalDuration,\n summary,\n ci: reports.find((r) => r.ci !== null)?.ci ?? null,\n metadata: reports.find((r) => r.metadata !== null)?.metadata ?? null,\n timeline: allTimelines,\n shardRunIds,\n };\n\n // Write to disk\n const dir = dirname(options.output);\n mkdirSync(dir, { recursive: true });\n writeFileSync(options.output, JSON.stringify(merged, null, 2), 'utf-8');\n\n return merged;\n}\n\nfunction recalculateSummary(reports: TestRunReport[]): Summary {\n let total = 0;\n let passed = 0;\n let failed = 0;\n let flaky = 0;\n let skipped = 0;\n let timedout = 0;\n\n for (const report of reports) {\n total += report.summary.total;\n passed += report.summary.passed;\n failed += report.summary.failed;\n flaky += report.summary.flaky;\n skipped += report.summary.skipped;\n timedout += report.summary.timedout ?? 0;\n }\n\n return { total, passed, failed, flaky, skipped, timedout };\n}\n"],"mappings":";AAOA,SAAS,kBAAkB;AAC3B,SAAS,cAAc,eAAe,iBAAiB;AACvD,SAAS,eAAe;AAOxB,SAAS,sBAAsB,aAAa,iBAAiB;AAE7D,eAAsB,aACpB,OACA,SACwB;AACxB,QAAM,UAA2B,CAAC;AAElC,aAAW,QAAQ,OAAO;AACxB,QAAI;AACJ,QAAI;AACF,YAAM,aAAa,MAAM,OAAO;AAAA,IAClC,SAAS,KAAK;AACZ,YAAM;AAAA,QACJ,UAAU;AAAA,QACV,wBAAwB,IAAI;AAAA,QAC5B;AAAA,MACF;AAAA,IACF;AAEA,QAAI;AACJ,QAAI;AACF,eAAS,KAAK,MAAM,GAAG;AAAA,IACzB,SAAS,KAAK;AACZ,YAAM;AAAA,QACJ,UAAU;AAAA,QACV,yBAAyB,IAAI;AAAA,QAC7B;AAAA,MACF;AAAA,IACF;AAEA,QAAI,CAAC,qBAAqB,MAAM,GAA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ClC,YAAU,KAAK,EAAE,WAAW,KAAK,CAAC;AAClC,gBAAc,QAAQ,QAAQ,KAAK,UAAU,QAAQ,MAAM,CAAC,GAAG,OAAO;AAEtE,SAAO;AACT;AAEA,SAAS,mBAAmB,SAAmC;AAC7D,MAAI,QAAQ;AACZ,MAAI,SAAS;AACb,MAAI,SAAS;AACb,MAAI,QAAQ;AACZ,MAAI,UAAU;AACd,MAAI,WAAW;AAEf,aAAW,UAAU,SAAS;AAC5B,aAAS,OAAO,QAAQ;AACxB,cAAU,OAAO,QAAQ;AACzB,cAAU,OAAO,QAAQ;AACzB,aAAS,OAAO,QAAQ;AACxB,eAAW,OAAO,QAAQ;AAC1B,gBAAY,OAAO,QAAQ,YAAY;AAAA,EACzC;AAEA,SAAO,EAAE,OAAO,QAAQ,QAAQ,OAAO,SAAS,SAAS;AAC3D;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testrelic/playwright-analytics",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Playwright custom reporter and navigation-tracking fixture for test analytics",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -50,7 +50,7 @@
50
50
  "@playwright/test": ">=1.35.0"
51
51
  },
52
52
  "dependencies": {
53
- "@testrelic/core": "1.0.0"
53
+ "@testrelic/core": "1.1.0"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@playwright/test": "^1.35.0",