Building a Zero-Dependency Playwright Summary Reporter
Why I shipped a GitHub Actions summary reporter with no runtime dependencies — and the design decisions that kept it that way, plus what it looks like in a real CI log.
The problem: the summary is where nobody looks
Every CI pipeline has the same gap. The artifacts live, the logs are twelve thousand lines, and the one thing a human actually wants — did it pass, which specs failed, how long did it take — is buried in scroll.
GitHub solved the reading problem years ago with GITHUB_STEP_SUMMARY: write Markdown to a file in the environment and it renders at the top of the job. But the reporter that fills it is usually a dependency. And a dependency in a reporter is a dependency every consumer now inherits, audits, and eventually upgrades.
The zero-dependency constraint
I set the rule before writing a line: this reporter must add nothing to a consumer's dependency graph. No markdown library, no date library, no table renderer. Playwright is a peer dependency and is not installed.
It sounds like a constraint that costs a lot of convenience. In practice it costs one thing — the table has to be built by string concatenation — and it buys something much larger. A consumer can add this reporter to a locked, audited pipeline and know that the tree did not change.
import type { FullResult, Reporter } from '@playwright/test/reporter';
import { appendFile } from 'node:fs/promises';
// Resolve GITHUB_STEP_SUMMARY. Absent outside GitHub Actions, and the
// reporter simply becomes a no-op — it must never break a local run.
const summaryFile = process.env.GITHUB_STEP_SUMMARY;
// A minimal table builder. No dependency, no library — just pipes.
function table(headers: string[], rows: string[][]): string {
const line = (cells: string[]) => `| ${cells.join(' | ')} |`;
const sep = `| ${headers.map(() => '---').join(' | ')} |`;
return [line(headers), sep, ...rows.map(line)].join('\n');
}
class SummaryReporter implements Reporter {
private started = Date.now();
onBegin(): void {
this.started = Date.now();
}
async onEnd(result: FullResult): Promise<void> {
if (!summaryFile) return;
const duration = ((Date.now() - this.started) / 1000).toFixed(1);
const rows = this.browsers.map((b) => [
b.name,
`${b.passed}/${b.total}`,
`${b.failed} failed`,
`${b.duration}s`,
]);
const markdown = [
'### Playwright Results',
'',
table(['Browser', 'Passed', 'Failed', 'Duration'], rows),
'',
`**Status:** ${result.status} · **Total:** ${duration}s`,
].join('\n');
await appendFile(summaryFile, `${markdown}\n`, 'utf8');
}
}
export default SummaryReporter;
Reading the browser matrix without Playwright internals
The interesting constraint is per-browser reporting. The reporter API gives you a flat list of test cases, each with a projectName — it does not give you a browser-by-browser breakdown for free.
So the reporter builds its own matrix: it buckets results by project name, tracks the first and last timestamp per bucket to derive duration, and renders a row per browser. It also handles the case where a browser did not run at all — that row still appears, marked skipped, because "Firefox never executed" is information a reviewer needs.
- Bucket test cases by
projectNameto reconstruct the browser matrix - Derive per-browser duration from first-to-last timestamp, not from sum of test times
- Render rows for browsers that did not run — silence is not the same as success
- Write to
GITHUB_STEP_SUMMARYonly when the env var is present, so local runs are unaffected
The part I would do differently
I shipped v1 without a "rerun locally" hint in the summary. The single most common reaction from users was "how do I re-run just that failure?", and the answer was buried in CI logs.
The fix was one line in the summary output — a copyable command with the failing project and grep filter already applied. It turned the reporter from "a report" into "the first step of the next action".
Key Takeaways
- Zero runtime dependencies is a real constraint worth honouring — consumers inherit every dependency a reporter adds.
-
GITHUB_STEP_SUMMARYis the right target: it puts the answer at the top of the job, not in the scroll. - A reporter must never break a local run — no-op cleanly when the CI env var is absent.
- Reconstruct the browser matrix yourself; the reporter API gives you a flat case list, not a breakdown.
- Put the re-run command in the summary. A report should be the first step of the next action.
Md Salekin Newaz is a Senior Software QA Engineer and ISTQB® Certified professional at Brain Station 23, based in Dhaka, Bangladesh and working with global clients on Playwright automation, AI-driven QA and CI/CD integration. See his portfolio and case studies — or read his resume.
Top comments (0)