Advanced
History & Flakiness Trending
After each run the reporter appends a compact entry to a local JSON file. The detailed template reads that file to render a pass-rate sparkline and a flakiness table showing your top flakiest tests over time.
Overview
Two things are built from history data and shown in the detailed template:
- Pass-rate trend — a mini sparkline and delta showing how your overall pass rate changed across the last N runs.
- Flakiness table — top-N tests ranked by flake rate, each with a per-test dot sparkline (amber dot = flaky in that run).
Both sections are controlled by showTrend (default true). They appear once at least two history entries exist.
Setup
Zero configuration needed for local development. History is written automatically to ~/.reportforge/history.json.
// playwright.config.tsreporter: [['@reportforge/playwright-pdf', { template: 'detailed', // historyFile defaults to ~/.reportforge/history.json}]]The sparkline and flakiness table appear automatically once two or more runs have been recorded. No extra configuration required.
CI caching
Ephemeral CI runners discard the workspace after each run. Set historyFile to a project-relative path and cache it between runs so history accumulates across CI jobs.
// playwright.config.tsreporter: [['@reportforge/playwright-pdf', { template: 'detailed', historyFile: '.reportforge/history.json',}]]# .github/workflows/test.yml- uses: actions/cache@v4 with: path: .reportforge/history.json key: reportforge-history-${{ github.ref }} # Omit restore-keys — cross-branch fallback causes misleading sparklines on PRs- run: npx playwright test env: RF_LICENSE_KEY: ${{ secrets.RF_LICENSE_KEY }} PUPPETEER_EXECUTABLE_PATH: /usr/bin/google-chrome-stableUsing github.ref as the cache key keeps history separate per branch. Drop restore-keys entirely on PR branches — cross-branch history makes the sparkline misleading.
Monorepo
In a monorepo with multiple Playwright configs, give each config its own historyFile so runs from different packages do not overwrite each other.
// packages/frontend/playwright.config.tsreporter: [['@reportforge/playwright-pdf', { historyFile: '.reportforge/frontend-history.json', outputFile: 'reports/{date}-frontend.pdf',}]]// packages/api/playwright.config.tsreporter: [['@reportforge/playwright-pdf', { historyFile: '.reportforge/api-history.json', outputFile: 'reports/{date}-api.pdf',}]]Flakiness table
The detailed template shows a Top flaky tests table below the pass-rate trend card. Each row shows the test name, flake rate, how many runs it was flaky in, and a dot sparkline across stored history (amber dot = flaky in that run, grey = clean).
reporter: [['@reportforge/playwright-pdf', { template: 'detailed', flakinessTopN: 5, // default — show top 5 flakiest tests // set 0 to hide the table entirely}]]The flakiness table is gated on showTrend: true (the default) and only appears when history contains at least one qualifying run. Runs recorded before this feature was introduced are excluded from the flake-rate denominator — the table fills in correctly as newer runs accumulate. No history migration needed.
A test is counted as flaky when Playwright marks it flaky — i.e. it failed on at least one retry attempt but ultimately passed.
Options reference
| Option | Default | Description |
|---|---|---|
| historyFile | ~/.reportforge/history.json | Path to the local history JSON. Relative paths resolved from cwd at startup. |
| historySize | 10 | Maximum number of past runs to retain (integer ≥ 2). Older entries are pruned on each write. |
| showTrend | true | Set to false to disable history write and both trend sections entirely. |
| flakinessTopN | 5 | Maximum flaky tests to display in the flakiness table. Set to 0 to hide the table. |