Below is a list of commonly used Playwright commands for testing and debugging:
- Install Playwright:
npm init playwright@latest
- Run all test cases:
npx playwright test - Show the test report:
npx playwright show-report
- Run tests for a specific project (e.g., Chromium):
npx playwright test --project=chromium - Run tests in headed mode (with browser UI):
npx playwright test --project=chromium --headed - Run a specific test file:
npx playwright test example.spec.ts --project=chromium - Run a specific test case by name:
npx playwright test -g "has title" --project=chromium
- Run tests in UI mode:
npx playwright test --ui - Run tests with tracing enabled:
npx playwright test --project=chromium --trace on - Run tests in debug mode:
npx playwright test --project=chromium --debug
- Update snapshots for visual testing:
npx playwright test --update-snapshots