How to Capture Playwright Performance Traces in GitHub Actions
Playwright can record a trace of a flow and expose browser performance timing, giving both a visual timeline and a number you can assert on.
Enable trace: on in the Playwright config, read performance.timing or the Performance API inside the page, and upload the trace as an artifact for the slow runs.
Steps
- Set
trace: 'on-first-retry'(oron) inplaywright.config.ts. - Read load timing from
page.evaluate(() => performance.now())around a navigation. - Upload
test-results/so traces are available for review.
Test
tests/perf.spec.ts
import { test, expect } from '@playwright/test';
test('home loads within budget', async ({ page }) => {
const start = Date.now();
await page.goto('https://staging.example.com/');
await page.waitForLoadState('networkidle');
expect(Date.now() - start).toBeLessThan(4000);
});Workflow
.github/workflows/ci.yml
jobs:
e2e-perf:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20 }
- run: npm ci && npx playwright install --with-deps
- run: npx playwright test
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-traces
path: test-results/Gotchas
- Open a trace with
npx playwright show-traceto see network and timing waterfalls. - Wall-clock assertions are noisy on shared runners; allow generous margins.
Related guides
How to Measure Core Web Vitals in GitHub ActionsCapture lab Core Web Vitals (LCP, CLS, TBT) in GitHub Actions by running Lighthouse against a built site and…
How to Run a Performance Smoke Test After Deploy in GitHub ActionsRun a quick performance smoke test against a freshly deployed URL in GitHub Actions, failing the deploy job w…