mirror of
https://github.com/magnus919/agent-skills.git
synced 2026-09-19 15:36:29 +03:00
ac1beb117d
Add ONE tool skill for Playwright: SKILL.md covering E2E test authoring, selector robustness, network interception/mocking, parallel workers, CI integration, scraping/headless patterns, accessibility snapshot checks, and headed debugging; scripts/pwrun (agent-first smoke harness with --json, fixture-tested); templates/ test-suite scaffold; eight dated references; a schema-valid evals/evals.json (6 cases); a human-facing README; reverse routing from qa-methodology and frontend-engineering; top-level README index entry; and regenerated catalogs (llms.txt, marketplace, codex). Closes #244. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2.7 KiB
2.7 KiB
Parallel Workers and Sharding
Last Updated: 2026-08-03
Playwright runs each test in its own browser context — isolation is the default. Parallelism is about scaling that safely, and sharding is how large suites split across CI machines.
Workers
workersin the config caps how many parallel worker processes run at once. Each worker hosts one browser instance and runs one test at a time.fullyParallel: truelets every spec file run across workers; with it off, only files in separate projects run in parallel.- Size workers to the machine, not to desire: each Chromium worker needs
roughly 300–500 MB. A 2-core/4 GB runner with 4 Chromium workers will OOM.
Start at
Math.min(cores, 4)and measure. - CI: pin
workers: 4(or--workers=4) for a stable runtime;undefinedlocally lets Playwright pick.
workers: process.env.CI ? 4 : undefined,
fullyParallel: true,
Sharding
Split one suite across multiple CI jobs:
npx playwright test --shard=1/4 # job 1 of 4
Each shard runs a disjoint set of tests; the HTML report aggregates via
merge-reports. Shard count should roughly equal runner count; the sharded
runtime is the slowest shard, so balance by spec-file count, not total tests
(Playwright shards by file).
Isolation traps (things that break parallel runs)
- Shared global state in the app under test — a localStorage flag, a
singleton cache, a shared DB row: workers race and tests interfere. Reset
per test (fixtures that clean up,
test.beforeEachseeding). - Shared files on disk — screenshots/traces written to the same path from
two workers. Give each test its own output dir (
test-results/<project>/is the default; don't override to one shared file). - Port collisions — multiple webServers or
page.goto('http://localhost:3000')hardcoded across workers. UsewebServerwith one process, or unique ports per project. - Test-order dependence —
describe.only/test.skippatterns, tests that assume a previous test ran. Every test must pass alone (--grepit) and in any order (--workers=1 --repeat-each=3to check determinism).
Verifying parallelism is working
scripts/pwrun inventory --json # suite shape
npx playwright test --list # what will run
npx playwright test --workers=4 # parallel run
Compare --workers=1 vs --workers=4 wall time: healthy suites scale ~linearly
until CPU-bound. If the parallel run is slower or flakier than serial, you
have an isolation trap — see above.
Related
- CI job wiring for shards and artifacts:
05-ci-integration.md. - Hermetic mocking so workers don't depend on live external APIs:
03-network-interception-and-mocking.md.