🎭 Playwright

🧭 Local vs Test Server

🏠 Local

  • Installing Playwright locally has several advantages:
    • Control over selectors & locators
Bash
$npm init playwright@latest
Click to copy

πŸ›©οΈ Test Server

  • Using Playwright to test a separate test server means creating a new test repository pretty much only to install Playwright and hold your tests, while targetting the test server as the test target.
Bash
$await page.goto('https://example.com');
Click to copy

πŸ”¬ Playwright Test Modes & Flags

  • Headed: npx playwright test --headed
  • Debug: npx playwright test --debug
  • UI: npx playwright test --ui
  • Show Report: npx playwright show-report

πŸ—ΊοΈ Scoping

  • Specific test
Bash
$npx playwright test tests/specific-test.spec.ts
Click to copy
  • Specific line of test (on line 10)
Bash
$npx playwright test tests/specific-test.spec.ts:10
Click to copy
  • Specific tag of test
Bash
$npx playwright test --grep '@smoke'
Click to copy