UNPKG

donobu

Version:

Create browser automations with an LLM agent and replay them as Playwright scripts.

66 lines 2.63 kB
/** * @fileoverview Donobu HTML Reporter for Playwright * * A Playwright reporter that generates a Donobu-branded HTML report directly, * without requiring a separate JSON post-processing step. * * @usage * ```ts * // playwright.config.ts * import { defineConfig } from 'donobu'; * export default defineConfig({ * reporter: [ * ['donobu/reporter/html', { outputFile: 'test-results/index.html' }], * ], * }); * ``` * * Optionally enrich the report with Donobu AI triage data: * ```ts * reporter: [ * ['donobu/reporter/html', { * outputFile: 'test-results/index.html', * triageDir: process.env.DONOBU_TRIAGE_DIR, * }], * ], * ``` * * During an auto-heal rerun (`DONOBU_AUTO_HEAL_ACTIVE=1`) the reporter skips * HTML generation. It always serializes its `DonobuReport` to a state file in * the Playwright JSON output directory so the orchestrator can pick it up, * merge it with the initial run's state, and re-render the HTML once. */ import type { FullConfig, FullResult, Reporter, Suite, TestCase, TestResult } from '@playwright/test/reporter'; export interface DonobuHtmlReporterOptions { /** Path to write the HTML report. Defaults to `test-results/index.html`. */ outputFile?: string; /** * Path to a Donobu triage run directory containing `treatment-plan-*.json` * and `failure-evidence-*.json` files. When provided, the report is enriched * with AI failure analysis. Corresponds to `--triage-dir` in the CLI. */ triageDir?: string; } export default class DonobuHtmlReporter implements Reporter { private readonly options; /** Accumulates all TestResult objects per TestCase (one per retry attempt). */ private readonly resultsByTest; private rootDir; constructor(options?: DonobuHtmlReporterOptions); onBegin(config: FullConfig, _suite: Suite): void; onTestEnd(test: TestCase, result: TestResult): void; onEnd(_result: FullResult): Promise<void>; printsToStdio(): boolean; /** * Drop a tiny redirect `index.html` into each Playwright-managed per-test * directory under `outputDir`. The stub points back at the combined report's * `#?testId=<id>` deep link, giving every test a stable URL inside its own * directory without duplicating any of the rendered HTML. * * Directories are discovered from `dirname(attachment.path)` — Donobu does * not invent any directory naming or layout. Tests with no attachments (and * therefore no Playwright-created directory) get no stub. */ private writePerTestStubs; } //# sourceMappingURL=html.d.ts.map