Skip to main content

Playwright Summary Reporter: Simplifying Playwright CI/CD Failure Analysis

Updated 12 min readMarkdown

Playwright Summary Reporter: Simplifying Playwright CI/CD Failure Analysis

A Playwright run produces everything you need to diagnose a failure — the assertion that broke, the locator that never resolved, the line number in the spec — but it scatters it across stdout, the HTML report, and the trace file. In CI, none of those are where anyone looks first.

This is the story of building playwright-summary-reporter: an open-source Playwright custom reporter that turns a test run into a readable Markdown dashboard, rendered directly in the GitHub Actions Job Summary. It is a zero-dependency package — the only imports are Node built-ins.

The Problem with Playwright CI/CD Reporting

The default list reporter prints one line per test. On a suite of 400 tests across three browsers, that is 400 lines of output, and the three lines that matter are buried somewhere in the middle. The dot reporter is worse for this — it compresses everything into characters precisely when you most want the detail.

The html reporter produces a genuinely useful report, but it is a file you have to download and open. A CI failure notification says "the job failed" and links to a log. The log is 12,000 lines. The reviewer has to scroll, or download an artifact, or re-run the suite locally to find out what broke.

The result is a familiar pattern: someone reads the failure out of the log by eye, copies the spec name, and re-runs it. The information needed to act is present, but it is not in the place where the decision gets made.

Why I Built This Package

I maintain CI pipelines for other people. When a pipeline fails, the first ten minutes are spent extracting the same four facts — which tests failed, where they live, what the error was, and what is the exact command to reproduce one of them. Doing that by hand, for every pipeline, is work that should not exist.

GitHub solved the rendering problem years ago with GITHUB_STEP_SUMMARY. Any process can append Markdown to the file named by that environment variable, and GitHub renders it at the top of the job summary. What was missing was a reporter that filled it with something worth reading.

The second constraint came from the consumers. A reporter is a dependency that every team inherits, audits, and eventually upgrades. So I set the rule before writing any code: this package must add nothing to a consumer's dependency graph. No Markdown library, no date library, no table renderer. Playwright itself is a peer dependency and is never installed.

What is Playwright Summary Reporter?

playwright-summary-reporter is a Playwright custom reporter that implements the Reporter interface and writes a Markdown summary of the run. It renders a status card, a proportional health bar, a KPI table, a Mermaid pie chart, per-project breakdowns, classified failures, a copy-ready re-run command and an AI debugging prompt.

It ships on npm as MIT-licensed TypeScript, with type declarations included. The published package has no runtime dependencies at all — fs and path are the only imports.

# install
npm install -D playwright-summary-reporter

# point Playwright at it
npx playwright test --reporter=playwright-summary-reporter

Key Features

Every section of the report is independently toggleable, so a consumer can strip the parts they do not want. The defaults are tuned for the common case: a CI run that needs to be read quickly.

  • GitHub-Flavored alert card — a green [!TIP] for a clean run, a red [!CAUTION] otherwise, carrying status, pass rate and the full breakdown
  • Proportional 12-block health bar visualising the result mix at a glance
  • KPI summary table with the headline metrics in bold
  • Native Mermaid pie chart — GitHub renders it, no image generation needed
  • Deterministic failure badges: Assertion, Timeout, Locator or Runtime
  • Copy-ready re-run command targeting exactly the failed tests
  • Collapsible AI debugging prompt bundling every failure for Copilot, Claude or Cursor
  • Per-project breakdown across browsers
  • Flaky test list with retry counts, and a top-N slowest-tests list with relative duration bars
  • Zero runtime dependencies, with TypeScript declarations shipped

Installation

The package is published on npm. Install it as a dev dependency, since it only runs at test time.

It requires Node.js 18 or newer and @playwright/test 1.40.0 or newer as a peer dependency. Playwright is never installed by this package — it is only imported as a type.

npm install -D playwright-summary-reporter

# requirements
#   node            >= 18.0.0
#   @playwright/test >= 1.40.0   (peer dependency)

Playwright Configuration

Register the reporter in playwright.config.ts. It is normally added alongside the default list reporter so the terminal output is unchanged and the summary is written in parallel.

The reporter name resolves to the package's entry point. You can also point Playwright at the compiled file directly, which is useful when the package is installed outside the project.

import { defineConfig } from '@playwright/test';

export default defineConfig({
  reporter: [
    ['list'],
    ['playwright-summary-reporter', { outputFile: 'test-summary.md' }],
  ],
});

GitHub Actions Integration

This is the part that requires no wiring at all. The reporter detects GITHUB_STEP_SUMMARY from the environment, so a completely standard workflow is enough — the summary appears in the Job Summary tab of the run.

The Markdown file is still written to disk as usual, so you can archive it as an artifact or commit it if you want a history.

name: Playwright Tests

on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: npm ci
      - run: npx playwright install --with-deps chromium
      - run: npx playwright test

Example Report Output

Here is what a failing run renders. The alert card states the outcome, the health bar shows the mix, the KPI table carries the numbers, and the Mermaid chart gives the distribution in one glance.

The report is Markdown that goes straight into the GitHub Actions job summary, so the raw output looks like this:

## Playwright Test Summary

> [!CAUTION]
>
> ### ❌ FAILED — 60% pass rate
>
> `🟩🟩🟩🟩🟩🟩🟥🟥🟥🟨⬜⬜` **Health Bar**
>
> ✅ **Passed:** 6 • ❌ **Failed:** 3 • ⚠️ **Flaky:** 1 • ⏭️ **Skipped:** 2
>
> 📊 **Total:** 12 • ⏱️ **Duration:** 12.4s
>
> ⏱️ **Timed Out:** 1 (counted within Failed)

The KPI table underneath it:

Metric Value
✅ Passed 6
❌ Failed 3
⚠️ Flaky 1
⏭️ Skipped 2
📊 Total 12
🎯 Pass Rate 60%
⏱️ Duration 12.4s

And the failed tests, each with its project and the exact line to look at:

Type Test Project Location Error
🎯 Assertion authentication › should reject invalid password firefox tests/auth/login.spec.ts:24 Error: expect(received).toBe(expected)
⏱️ Timeout payment › should validate expired card chromium tests/payment/card.spec.ts:55 Error: Test timeout of 5000ms exceeded.

The Mermaid chart renders the distribution in one glance:

pie showData
    title Test Results Distribution
    "Passed" : 6
    "Failed" : 3
    "Flaky" : 1
    "Skipped" : 2

Failed Test Re-run Commands

The report ends with the command that reproduces exactly the failures — no grep filter, no scrolling to find the right line. Each failed test contributes file:line, which is Playwright's native way of targeting a single test, and duplicates are removed so a file with three failures contributes one entry per distinct line.

This is the feature that turned the reporter from "a report" into "the first step of the next action".

npx playwright test tests/auth/login.spec.ts:24 tests/payment/card.spec.ts:55

AI-Ready Debugging Context

The report includes a collapsible accordion containing a ready-to-paste debugging prompt. It bundles every failure with its category, project, location, duration, retry count and error message, so an assistant can triage the run without needing to re-read the log or open the trace.

The prompt asks for the most likely root cause of each failure, an explanation of what the assertion or locator actually observed, a concrete minimal fix, and a flag on anything that looks like a race condition or an unstable locator. The final instruction asks for a prioritised list of root causes and the exact code changes required.

You are triaging a failing Playwright test run ("Playwright Test Summary").

For each failing test below:
1. Identify the most likely root cause of the failure.
2. Explain what the assertion or locator actually observed.
3. Propose a concrete, minimal fix to the test or the application code.
4. Flag anything that looks like a race condition or an unstable locator.

---

### 1. authentication › should reject invalid password

- **Category:** 🎯 Assertion
- **Project:** firefox
- **Location:** tests/auth/login.spec.ts:24
- **Duration:** 3.1s
- **Retries:** 0
- **Error:**

Error: expect(received).toBe(expected)

---

Please respond with a prioritised list of root causes and the exact code changes required to fix each failing test.

Technical Implementation

The reporter implements three methods of the Playwright Reporter interface: onBegin, onTestEnd and onEnd. Results are accumulated in a Map keyed by test id, because a test emits one result per retry attempt and only the last attempt carries the final verdict — keying by id means each attempt replaces the previous one and every test is counted exactly once.

Outcomes are resolved from test.outcome(), which is the authoritative final verdict because it accounts for retries and for tests that were expected to fail. The reporter distinguishes five outcomes — passed, failed, flaky, skipped and timedOut — but only four are used as buckets in the totals.

That distinction is the most important design decision in the package. A timeout is a kind of failure, not a separate bucket, so timedOut is folded into failed for all arithmetic and surfaced separately only as a badge and a line in the alert card. This guarantees the invariant total === passed + failed + flaky + skipped holds in every table, in the chart and in the KPI strip.

onTestEnd(test: TestCase, result: TestResult): void {
  // A test emits one result per retry attempt. We key records by the test id
  // so each attempt replaces the previous one — the last attempt is the one
  // that carries the final verdict, and the test is counted exactly once.
  const key = test.id;
  const outcome = this.resolveOutcome(test, result);
  const error = this.resolveError(result);

  this.records.set(key, {
    title: this.resolveTitle(test),
    project: this.resolveProject(test),
    file: this.resolveFile(test),
    line: test.location?.line ?? 0,
    duration: result.duration,
    retries: result.retry,
    outcome,
    ...(error ? { error } : {}),
    ...(outcome === 'failed' || outcome === 'timedOut'
      ? { category: classifyFailure(error, outcome) }
      : {}),
  });
}
  • The browser matrix is reconstructed by walking up the suite tree to the ancestor of type project — the reporter API gives a flat case list, not a breakdown
  • Test titles are joined with › and the spec filename segment is dropped, because the file is already shown in the Location column
  • Error messages are stripped of ANSI escapes, collapsed to one line and truncated at a word boundary
  • Markdown pipes are escaped in exactly one place — the table cell renderer — so a pipe in an error message cannot break the table
  • The health bar is always exactly 12 characters wide, with segments allocated by largest-remainder rounding so the counts sum back to the total

Future Improvements

The package is at v2.1.2 on npm. The direction I want to take it is not more visual polish — it is more portability and more machine-readability.

  • A JSON output mode alongside the Markdown one, for pipelines that want to diff or gate on the result programmatically
  • Support for other CI providers that expose a step-summary equivalent
  • A JUnit-style XML emitter for consumers whose dashboards already understand that format
  • Configurable failure-category patterns, so teams can map their own error vocabulary onto the badge set

Conclusion

The reporter does not make Playwright faster, and it does not make failing tests pass. It makes the failure legible at the moment someone needs to read it.

The two ideas that made it work are unglamorous. First: put the answer where the decision happens, not where the detail lives. Second: a report should be the first step of the next action, not the last step of the previous one — which is why the re-run command and the AI prompt are first-class parts of the output rather than extras.

And the constraint that shaped everything else — zero runtime dependencies — turned out to be a feature rather than a cost. A consumer can drop this into a locked, audited pipeline and know the dependency tree did not change.

About the Author

Md Salekin Newaz is a Senior Software QA Engineer at Brain Station 23 and an ISTQB® Certified professional. He works across test automation, API and performance testing, and CI/CD integration.

playwright-summary-reporter is MIT-licensed and open source. If it saves you time in your pipeline, or if you want to contribute a failure category or a CI provider adapter, the issue tracker is open.


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.

About the author

  • I build small, sharp developer tools for Playwright CI. Currently: playwright-summary-reporter, a zero-dependency reporter that writes a Markdown dashboard into the GitHub Actions Job Summary. I write about test automation, CI ergonomics, and the DX of failing builds.

No comments yet. Be the first to comment.