Guide · November 13, 2026 · 13 min read
From test run to dashboard: Playwright test analytics, the VERA case
How to turn every Playwright run into a pass rate and a flaky-test ranking: a reporter that keeps the last attempt, a local receiver to watch it travel, and how VERA is tested (domain, reporter and ingestion against embedded Postgres).
A Playwright suite running in CI leaves one verdict per run: green or red. What it does not leave is memory. To know whether a test fails one time in ten, whether the pass rate is drifting down, or whether a red is new or has been there for three weeks, you have to store every run and compare it with the earlier ones.
That is what VERA does, the test analytics product I am building at The Virginia: a reporter uploads each run and a dashboard turns it into pass rate, trend, a flaky-test ranking and failure detail. In this guide I use it as a case study in two ways: how a real suite gets connected, and how you test a product whose job is to judge other people's tests.
VERA's repository is private, so you will not be able to clone it. To keep the guide reproducible anyway, steps 1 to 3 build an equivalent reporter and a local receiver with complete code: that is enough to watch a run travel end to end on your machine. Steps 4 to 6 show the same against VERA (v0.3.0), with the output I got.
How it fits together
Playwright suite (your CI)
│ onTestEnd once per attempt → the reporter keeps the last one
▼
reporter ── POST /api/v1/runs (JSON + project API key)
▼
VERA
├─ validates the payload (zod) and summarizes: total, passed, failed, skipped, flaky
├─ stores the run and its results (Postgres)
└─ dashboard: pass rate, trend, flaky ranking, failure detailRequirements
- Node.js 22 or newer (I used 22.23.4).
@playwright/test. Everything in this guide ran on version 1.65.0.- Ten minutes for steps 1 to 3. No browsers to install: the example tests do not open one.
Setup
mkdir reporter-demo && cd reporter-demo
npm init -y
npm install -D @playwright/test
npx playwright --version # Version 1.65.0import { defineConfig } from "@playwright/test";
export default defineConfig({
testDir: "./tests",
retries: 1,
reporter: [["list"], ["./run-reporter.ts"]],
projects: [{ name: "api" }],
use: { baseURL: process.env.TARGET_URL ?? "http://localhost:3100" },
});Step by step
1. Three tests that behave differently
To see what a reporter does you need the three cases that matter: a stable test, one that only passes on retry and a broken one. The last two fail on purpose.
import { expect, test } from "@playwright/test";
test("adds two prices", () => {
expect(1999 + 501).toBe(2500);
});
// Fails on the first attempt on purpose: this is what a flaky test looks like to a reporter.
test("passes only on retry", ({}, testInfo) => {
expect(testInfo.retry).toBe(1);
});
// Wrong on purpose, to see a failure travel to the receiver.
test("expects the wrong total", () => {
expect(1999 + 501).toBe(2600);
});2. A reporter that keeps the last attempt
Playwright calls onTestEnd once per attempt, not once per test. Upload every call and a test that passed on its second attempt counts as one failure and one pass. VERA's design decision is to store the final outcome of each test and record how many retries it took: since the Map key is test.id, the last attempt overwrites the earlier ones.
import type { FullResult, Reporter, TestCase, TestResult } from "@playwright/test/reporter";
type Status = "passed" | "failed" | "skipped";
interface ResultRow {
testKey: string;
title: string;
file: string;
browser: string;
status: Status;
retries: number;
durationMs: number;
error: string | null;
}
const ANSI = /\u001b\[[0-9;]*[A-Za-z]/g;
export default class RunReporter implements Reporter {
private readonly results = new Map<string, ResultRow>();
private startedAt = new Date();
printsToStdio() {
return false; // keep the "list" reporter output on screen
}
onBegin() {
this.startedAt = new Date();
}
onTestEnd(test: TestCase, result: TestResult) {
const browser = test.parent.project()?.name ?? "";
// titlePath(): ["", project, file, ...describes, title]
const [, , file = "", ...path] = test.titlePath();
const title = path.join(" › ");
const status: Status = result.status === "passed" ? "passed" : result.status === "skipped" ? "skipped" : "failed";
const error = result.errors.map((e) => e.message ?? "").join("\n").replace(ANSI, "").slice(0, 10_000);
// onTestEnd fires once per attempt. Same test.id → the last attempt overwrites the earlier ones.
this.results.set(test.id, {
testKey: [browser, file, title].filter(Boolean).join(" › "),
title,
file,
browser,
status,
retries: result.retry,
durationMs: Math.round(result.duration),
error: error || null,
});
}
async onEnd(full: FullResult) {
const url = process.env.VERA_URL;
const apiKey = process.env.VERA_API_KEY;
if (!url || !apiKey) return console.log("[reporter] VERA_URL or VERA_API_KEY not set, skipping upload.");
try {
const res = await fetch(new URL("/api/v1/runs", url), {
method: "POST",
headers: { "content-type": "application/json", authorization: `Bearer ${apiKey}` },
body: JSON.stringify({
branch: process.env.GITHUB_REF_NAME ?? "",
commitSha: process.env.GITHUB_SHA ?? "",
startedAt: this.startedAt.toISOString(),
durationMs: Math.round(full.duration),
results: [...this.results.values()],
}),
});
console.log(res.ok ? `[reporter] Run uploaded (${res.status}).` : `[reporter] Upload failed: HTTP ${res.status}`);
} catch (err) {
// Reporting must never turn a green run red.
console.log(`[reporter] Upload failed: ${err instanceof Error ? err.message : err}`);
}
}
}Three details that come from using it for real. printsToStdio() returns false so it does not hide the list reporter's output. expect() messages arrive with terminal color codes, so they have to be cleaned before storing them. And the try/catch in onEnd is not tidiness: a reporter that breaks the pipeline when the metrics server is down stays installed for about a week.
3. Watch it travel: a 15-line receiver
Before pointing at a real service, look at what goes over the wire. This receiver accepts the same POST /api/v1/runs and summarizes what it got:
import { createServer } from "node:http";
createServer(async (req, res) => {
if (req.method !== "POST" || req.url !== "/api/v1/runs") return res.writeHead(404).end();
let body = "";
for await (const chunk of req) body += chunk;
const run = JSON.parse(body);
const count = (status) => run.results.filter((r) => r.status === status).length;
const flaky = run.results.filter((r) => r.status === "passed" && r.retries > 0);
console.log(`run: ${run.results.length} tests, ${count("passed")} passed, ${count("failed")} failed, ${flaky.length} flaky`);
for (const r of flaky) console.log(` flaky: ${r.testKey} (retries: ${r.retries})`);
for (const r of run.results.filter((r) => r.status === "failed")) console.log(` failed: ${r.testKey}\n ${r.error?.split("\n")[0]}`);
res.writeHead(201, { "content-type": "application/json" }).end(JSON.stringify({ id: "local" }));
}).listen(4000, () => console.log("receiver listening on http://localhost:4000"));node receiver.mjs # terminal 1
VERA_URL=http://localhost:4000 VERA_API_KEY=local npx playwright test # terminal 2Running 3 tests using 1 worker
✓ 1 [api] › tests/demo.spec.ts:3:1 › adds two prices (6ms)
✘ 2 [api] › tests/demo.spec.ts:8:1 › passes only on retry (5ms)
✓ 3 [api] › tests/demo.spec.ts:8:1 › passes only on retry (retry #1) (7ms)
✘ 4 [api] › tests/demo.spec.ts:13:1 › expects the wrong total (5ms)
✘ 5 [api] › tests/demo.spec.ts:13:1 › expects the wrong total (retry #1) (10ms)
1 failed
1 flaky
1 passed (1.7s)
[reporter] Run uploaded (201).receiver listening on http://localhost:4000
run: 3 tests, 2 passed, 1 failed, 1 flaky
flaky: api › demo.spec.ts › passes only on retry (retries: 1)
failed: api › demo.spec.ts › expects the wrong total
Error: expect(received).toBe(expected) // Object.is equalityThat is the point of the whole guide: Playwright printed five lines and the receiver got three results. passes only on retry arrived as passed with retries: 1. On the console that gets lost between lines; in the data it is flagged. Without the environment variables the reporter says so and uploads nothing ([reporter] VERA_URL or VERA_API_KEY not set, skipping upload.), and with the receiver stopped it logs [reporter] Upload failed: fetch failed without touching the suite's exit code.
4. The same against VERA
With VERA the reporter comes packaged and the configuration is one line. Each project has its own API key, shown once when it is created: the server only stores its SHA-256 hash.
// playwright.config.ts
export default defineConfig({
retries: 1,
reporter: [["list"], ["@vera/playwright-reporter", { environment: "local" }]],
});VERA_URL=http://localhost:3100 VERA_API_KEY=vera_... npx playwright testFor this guide I ran a five-test suite against a local instance, targeting VERA's own API: three pass, one passes only on retry and one expects a status the API never returns.
import { expect, test } from "@playwright/test";
test.describe("ingestion API", () => {
test("health check answers ok", async ({ request }) => {
const res = await request.get("/api/health");
expect(res.status()).toBe(200);
expect(await res.json()).toEqual({ status: "ok" });
});
test("rejects uploads without an API key", async ({ request }) => {
const res = await request.post("/api/v1/runs", { data: {} });
expect(res.status()).toBe(401);
});
test("rejects an empty run", async ({ request }) => {
const res = await request.post("/api/v1/runs", {
headers: { authorization: `Bearer ${process.env.VERA_API_KEY}` },
data: { startedAt: new Date().toISOString(), durationMs: 0, results: [] },
});
expect(res.status()).toBe(400);
});
// Fails on the first attempt on purpose, to see how a flaky test is reported.
test("passes only on retry", async ({}, testInfo) => {
expect(testInfo.retry).toBe(1);
});
// Wrong on purpose, to see a failure in the dashboard.
test("expects a status the API never returns", async ({ request }) => {
expect((await request.get("/api/health")).status()).toBe(418);
});
}); 1 failed
1 flaky
3 passed (2.1s)
[vera] Run uploaded: http://localhost:3100/projects/web-store/runs/<id>5. Verify that ingestion worked
Do not assume it uploaded because the suite finished. There are three cheap checks, in this order: the [vera] Run uploaded line with the run URL in the CI log; GET /api/health, which in v0.3.0 answers {"status":"ok"} when the app reaches the database; and opening the run URL to confirm the counters match Playwright's summary (here: 5 tests, 1 failed, 1 flaky).
The API answers with status codes you can assert on, and three of the five tests above do exactly that: 401 without an API key, 400 for a run with no results, 201 when the run is stored. A body over 10 MB gets 413.
6. Read the dashboard

- Pass rate 80%: passed over executed, 4 out of 5. Skipped tests are left out, so skipping tests does not raise the number. The test that passed on retry counts as passed.
- Flaky tests: 1:
passes only on retryshows0 failed, 3 retried of 3and 100% instability. Its final outcome never failed, but it needed a retry all three times. - The broken test is not flaky:
expects a status the API never returnsalways fails, which is why it is not in the ranking. A test that always fails is broken, not unstable, and mixing them hides both. - Run detail: failures first, with their error message; then flaky, passed and skipped tests.
The full flaky rule, as it lives in VERA's domain, looks at a window of the last 20 runs:
// packages/core/src/flaky-tests.ts (excerpt)
const mixed = e.passes > 0 && e.failures > 0;
if (!mixed && e.retriedPasses === 0) continue; // stable, or always broken: not flaky
const executions = e.passes + e.failures; // skipped runs do not count
const unstable = mixed ? e.failures + e.retriedPasses : e.retriedPasses;
flakinessRate = Math.min(unstable / executions, 1);How VERA itself is tested
A product that measures the quality of other people's tests cannot have weak ones of its own. VERA's suite has three layers plus an end-to-end check, and none of them needs Docker or external services.
- Domain (
packages/core): pure functions, no database, no network. The rules that define the product live here: what counts toward the pass rate and what is flaky. Each rule has its case: passes and fails across runs, passes only with retries, always broken, always stable. - Reporter (
packages/playwright-reporter): instantiated with an injectedfetchand minimalTestCaseobjects. It checks that the last attempt wins, that nothing is uploaded without credentials and that a network error never throws. - Ingestion (
apps/web): the use cases run against real Postgres, but embedded. PGlite starts an in-memory Postgres inside the test process and applies the same migrations production uses. - Dogfooding: a real Playwright suite reports to VERA through the compiled reporter. The repo ships one against The Virginia's site (
examples/playwright-demo); for this guide I used the one from step 4, against VERA's own API.
// apps/web/src/modules/runs/ingest-run.test.ts (excerpt)
describe("run ingestion (embedded Postgres)", () => {
let db: Database;
beforeAll(async () => {
db = await createDatabase("memory:"); // in-memory PGlite + the real migrations
});
it("rejects missing or unknown API keys", async () => {
const payload = { startedAt: new Date(), durationMs: 1, results: [result("a", "passed")] };
expect(await ingestRun(db, null, payload)).toMatchObject({ ok: false, status: 401 });
expect(await ingestRun(db, "vera_nope", payload)).toMatchObject({ ok: false, status: 401 });
});
});The third decision pays off the most. Use cases take the database as a parameter, so the test injects an in-memory one and exercises real SQL (constraints, cascades, transactions) with no ORM mocks. The cost is low: the full v0.3.0 suite runs in about three seconds.
$ npm test
RUN v5.1.0
Test Files 5 passed (5)
Tests 25 passed (25)
Duration 3.14sWhat dogfooding found
All three layers were green, and the first real run still showed two things no unit test could see.
First: errors were stored with ANSI codes. The reporter's test used hand-written error messages (boom, timeout), while the ones expect() produces are colored for the terminal. In the dashboard a failure read like this:
Error: [2mexpect([22m[31mreceived[39m[2m).[22mtoBe[2m([22m[32mexpected[39m[2m) // Object.is equality[22m
Expected: [32m418[39m
Received: [31m200[39mThe fix was one regular expression and a new test that uses the exact message Playwright emitted, not an invented one.
Second: I created the project from the command line with the development server already running, and the first three runs ended like this:
[vera] Upload failed: HTTP 401 {"error":"Invalid or missing API key."}The key was valid. PGlite serves one process at a time: the server had its own copy of the database open and did not see the project the other process had just created until I restarted it. Real Postgres does not behave that way. It is documented now, and it also confirmed that the reporter's design works: the suite reported its normal result and the upload problem stayed in one log line.
Common mistakes
- Uploading one result per attempt instead of one per test: it inflates failures and makes flaky tests disappear.
- Counting skipped tests in the pass-rate denominator, or treating an always-broken test as flaky.
- Letting the reporter fail the pipeline when the metrics service does not answer.
- Testing the reporter only with invented error messages and never with a real run.
- Renaming a test or the Playwright project and expecting it to keep its history: identity is
project › file › title. - Committing the API key. It belongs in CI secrets.
Checklist: how to know it is done
- The receiver (or VERA) gets one result per test even when there are retries.
- The test that passes on retry arrives as
passedwithretriesabove zero. - With the server stopped, the suite ends with the same exit code as without the reporter.
- The stored error message reads as plain text.
- After three runs, the unstable test is in the flaky ranking and the broken one is not.
Where AI fell short
I built and verified this guide with an AI agent, and it failed where a person in a hurry fails: it trusted a check that was not looking at what it thought. It assumed the API key created from the CLI worked with the server running, and got three runs with 401 before questioning that. It considered the reporter healthy because its unit tests passed; the ANSI codes only showed up when the dashboard was opened. It wrote a browser check with a brittle wait that flagged a working login as broken. And it tested a new endpoint against an old process that was still alive, which returned a false 404. None of those were product bugs: all four were test bugs. That is why every result in this guide was checked against a real run and not against what the agent expected to see.
Frequently asked questions
Does it help if I do not use Playwright?
The idea does: any framework that exposes the result of each attempt lets you build the same payload. JUnit XML is the usual route for Selenium, Cypress or pytest, with one caveat worth knowing: several JUnit generators only keep the final outcome, so a test that passed on retry arrives as a plain pass and flakiness is only detected by comparing runs.
Why not just use Playwright's HTML reporter?
Because it answers a different question. The HTML report explains one run in great detail; it knows nothing about the previous one. Flakiness, trend and regressions are properties of a series of runs, and for that you have to store them somewhere.
Should I raise `retries` to get fewer reds?
Only if you look at what the retries hide. With retries and no record, an unstable test becomes invisible until the day it fails twice in a row. With the retry count stored, the same test shows up first in a ranking.
Gastón Genaud · gastongenaud.com · The Virginia