Goal
Run Playwright tests deterministically and return a pass/fail summary, the top failing tests with likely cause, and artifact paths (playwright-report/, test-results/, traces).
Rules
- •Prefer
npmscripts if present in package.json, else usenpx playwright. - •Default to headless unless user passed
--headed. - •Only run against localhost / internal env configured in
playwright.config.*. - •If Playwright or browsers are missing, install them using
scripts/ensure-playwright.sh. - •Always run with trace enabled on failure if not already configured.
Steps
1. Locate Playwright
- •If
package.jsonexists and includes@playwright/test, use project-local. - •Otherwise install as a dev dependency + browsers.
2. Ensure browsers installed
bash
bash plugins/playwright/skills/run/scripts/ensure-playwright.sh
3. Run tests
- •If
package.jsonhas atest:uiscript, runnpm run test:ui -- $ARGUMENTS - •Otherwise run
npx playwright test $ARGUMENTS
4. If failing — re-run with diagnostics
Re-run only failing tests once:
bash
npx playwright test --last-failed --trace=on --screenshot=only-on-failure
5. Summarize
- •Give a tight summary and list failing spec names.
- •Point to artifacts:
playwright-report/andtest-results/paths. - •Follow the structured output contract in
references/output-format.md.
Constraints
- •Never open arbitrary external URLs.
- •Do not start application servers unless explicitly instructed.
- •Keep trace files for debugging; do not delete them automatically.