π 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