Playwright has become the default choice for E2E testing in 2025. If you're starting from scratch, this guide will get you from zero to a production-ready test setup in under an hour.
Installation
npm init playwright@latest
# Choose TypeScript, tests folder, GitHub Actions, install browsersThis gives you a working setup with example tests, a config file, and optionally a GitHub Actions workflow.
Project structure
tests/
auth/
login.spec.ts
signup.spec.ts
checkout/
cart.spec.ts
payment.spec.ts
pages/
login.page.ts
checkout.page.ts
fixtures/
index.ts
playwright.config.tsYour first test
import { test, expect } from '@playwright/test';
test('homepage loads and shows title', async ({ page }) => {
await page.goto('/');
await expect(page).toHaveTitle(/My App/);
await expect(
page.getByRole('heading', { name: 'Welcome' })
).toBeVisible();
});Configuration essentials
Key settings in playwright.config.ts:
- baseURL: Set this so tests use relative URLs
- retries: Set to 1-2 in CI, 0 locally
- workers: Use all available cores locally, shard in CI
- reporter: Use
htmllocally andjunitin CI - use.trace: Set to
'on-first-retry'for debugging
Next steps
- Add page objects for complex pages (see my POM guide)
- Set up CI integration (see my CI/CD guide)
- Add API testing alongside E2E tests
- Set up visual regression testing
Need help setting up Playwright for your team? Get in touch. We do this for engineering teams every week.