CLI Cheatsheet
When to Use
Use this as a quick reference for running tests, updating baselines, and managing reports.
Pattern
Run tests
npx playwright test # all tests, all projects
npx playwright test --project=chromium-1440 # single project
npx playwright test --grep "homepage" # filter by title
npx playwright test e2e/homepage.spec.ts # filter by file
npx playwright test e2e/homepage.spec.ts:42 # by line number
npx playwright test --headed # visible browser
npx playwright test --ui # interactive UI mode
npx playwright test --workers=1 # serialize
Update baselines
npx playwright test --update-snapshots # = changed (mismatches + missing)
npx playwright test -u # short form
npx playwright test --update-snapshots --grep "button" # scoped update
npx playwright test --update-snapshots=all # all executed tests
npx playwright test --update-snapshots=missing # only create missing
npx playwright test --update-snapshots=none # never update
Reporter overrides
npx playwright test --reporter=html
npx playwright test --reporter=list,html
npx playwright test --reporter=json --output=results.json
HTML report viewer
npx playwright show-report
npx playwright show-report ./playwright-report
npx playwright show-report --port 8080
npx playwright show-report --host 0.0.0.0 # LAN sharing
Browser install
npx playwright install
npx playwright install chromium webkit
npx playwright install --with-deps
Codegen (bootstrap a test scaffold)
npx playwright codegen https://playwright.dev
npx playwright codegen --browser=firefox
Let the recorder generate navigation; add expect(page).toHaveScreenshot() manually.
Debug
npx playwright test --debug # PWDEBUG=1, headed, single worker
npx playwright test -x # stop on first failure
npx playwright test --list # list tests without running
Common Mistakes
- Wrong:
-uwithout--grep→ Right: accidentally updates the entire suite; always scope with--grep - Wrong:
--debugwithout realizing it implies--workers=1→ Right: slower; use only when actually debugging - Wrong:
show-reportwithout specifying path → Right: may open an old report; pass an explicit path
See Also
- Baseline Files
- Config Walkthrough
- Reference: Playwright CLI