Streams E2E test results to stats.sonicjs.com as tests finish — one file-batch at a time — so the dashboard updates live during a run rather than waiting for completion.
How it works
A custom Playwright Reporter class (tests/e2e/stats-live-reporter.ts) hooks into the test lifecycle:
Hook
Action
onBegin
POST /v1/playwright-runs/start — opens a running run record
onTestEnd
Buffer results by file; flush the file's batch when all its tests finish
onEnd
POST /:run_id/complete — recomputes final counts, seals the run
New API endpoints
POST /v1/playwright-runs/start — create a pending run
POST /v1/playwright-runs/:id/tests — append a batch of test results
POST /v1/playwright-runs/:id/complete — finalise with counts + status
The original POST /v1/playwright-runs batch endpoint is unchanged (still works for manual npm run e2e:report).
Dashboard changes
● live animated badge on in-progress rows in Recent Runs
Running rows sorted to the top
Main dashboard auto-reloads every 8 s while any run is live
Run detail page: green "in progress" banner + 5 s auto-refresh
Zero-config opt-out
Reporter self-disables when PLAYWRIGHT_STATS_API_KEY is not set — both locally (reads .dev.vars fallback) and in CI (empty on fork PRs that can't access secrets).
Adds live Playwright reporting and dashboard refreshes.
Playwright sends run results to stats as test files finish.
The stats API accepts run results before a Playwright run is finished.
Dashboard pages keep active Playwright runs up to date.
Diagram
sequenceDiagram
participant P as Playwright reporter
participant A as Stats API
participant D as Database
participant U as Dashboard
P->>A: Start run
A->>D: Save running record
loop Each finished file
P->>A: Append test results
A->>D: Insert test rows
end
U->>A: Reload dashboard
A->>D: Read run and test rows
P->>A: Complete run
A->>D: Count final attempts and save completion