Pin copy-pasteable npx invocations to explicit versions so agents executing them verbatim get reproducible behavior: - playwright docs: npx playwright@1.62.1 (SKILL.md, README.md, references 02-selectors / 05-ci-integration / 07-accessibility) - mermaid-diagrams: @mermaid-js/mermaid-cli@11.16.0 (SKILL.md, references/pdf-rendering-pipeline.md) - hugo-theme seo-outputs-testing: @axe-core/cli@4.13.0 - agent-skills using-scripts.md: strengthen version-pinning bullet into a normative rule for copy-pasteable commands Reword the anydoc cli-reference "Version pinning" prose so the anti-pattern is explained didactically without presenting an unpinned command as a recipe; the @0.1.6 house pin is unchanged. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
3.3 KiB
CI Integration
Last Updated: 2026-08-03
Playwright in CI is: install browsers + OS deps, pin the version, run the suite with retries and tracing, and surface a debuggable report. This reference assumes GitHub Actions; the same shape applies to any runner.
Minimal GitHub Actions workflow
name: e2e
on: [push, pull_request]
jobs:
e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20, cache: npm }
- run: npm ci
- run: npx playwright@1.62.1 install --with-deps chromium
- run: npx playwright@1.62.1 test
- if: failure()
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: playwright-report/
retention-days: 14
Non-negotiables
-
Install browsers with OS deps:
npx playwright@1.62.1 install --with-deps(not bareinstall) on Linux runners;--with-depsinstalls the system libraries Chromium/Firefox/WebKit need. -
Pin and cache:
npm ciwith a committedpackage-lock.json(nevernpm install).- Cache the browser download:
~/.cache/ms-playwright(Linux),~/Library/Caches/ms-playwright(macOS),%USERPROFILE%\AppData\Local\ms-playwright(Windows). - Cache
node_modulesvia the setup-nodecache: npmoption.
-
Retry flaky tests on CI only, with traces on retry so failures are debuggable:
retries: process.env.CI ? 2 : 0, use: { trace: 'on-first-retry' }, -
Configure
webServerin the config so the runner starts and waits for the app; never assume a long-lived dev server on a runner. -
Upload artifacts on failure: the HTML report, the JSON report, and the
test-results/dir (traces). Retention bounded (7–14 days) — see hard boundaries inSKILL.mdabout keeping evidence bounded.
Reporters
-
list/line— human-readable run output. -
html— the browsable report (upload on failure). -
json— the machine-readable report for agent triage:scripts/pwrun report --report test-results/test-results.json --jsonIt prints stats (expected/unexpected/flaky/skipped), the failing specs, and the error message from the last retry — enough to triage without opening a browser.
-
github— inline annotations on GitHub Actions, keyed to the failing spec line.
Sharding across jobs
For large suites, split the run:
strategy:
matrix:
shard: [1/4, 2/4, 3/4, 4/4]
steps:
- run: npx playwright@1.62.1 test --shard=${{ matrix.shard }}
Merge reports from all shards with playwright merge-reports (see
04-parallel-workers-and-sharding.md for the math).
Triage loop for a red CI run
scripts/pwrun report --report <json> --json— get the failing specs and messages.- Download the trace artifact (
trace.zip) and open it in the Trace Viewer to see the failing action, network, and console. - Classify: environment (missing dep/browser), selector (see
02-selectors.md), timing (webServer readiness,webServer.timeout), or app regression (real bug — the test did its job). - Fix, re-run, and confirm the shard matrix is green.
Related
- Parallelism and sharding configuration:
04-parallel-workers-and-sharding.md. - Trace reading and headed debugging:
07-accessibility-and-debugging.md.