Setting up a Playwright project
(Optional since you're middle — keep it for quick review.)
Setup: npm init playwright@latest — config, a sample test and browsers come ready.
The key parts of playwright.config.ts:
testDir— where tests liveuse— shared settings:baseURL,trace,screenshot,videoprojects— the browser/config matrix (chromium, firefox, webkit, mobile viewport)retries,workers— CI behaviourreporter— html, list, junit
Core commands: npx playwright test (run), --ui (interactive mode), --debug, npx playwright show-report, npx playwright codegen <url> (locator generator).
trace: 'on-first-retry' + retry=1 in CI — the golden combo for investigating flaky tests: the failure's full "black box" (DOM snapshots, network, console) opens in the trace viewer.
📚 Sources and documentation
- Installationofficialplaywright.dev
- Test configurationofficialplaywright.dev