Once Playwright is installed, structuring your test project well makes it easier to scale. A clear layout for tests, helpers, and configuration reduces friction when multiple people work on the same suite.
Typical Playwright Project Structure
The default scaffold arranges tests in a tests directory and uses playwright.config to control settings. You can customise folders later, but starting from the standard layout helps everyone navigate quickly.
playwright-demo/
ββ package.json
ββ playwright.config.ts
ββ tests/
β ββ example.spec.ts
β ββ auth.spec.ts
β ββ cart.spec.ts
ββ helpers/
ββ test-data.ts
ββ api-clients.ts
.spec.ts (or .test.ts) files under the configured test directory, so you rarely need manual file lists.auth.spec.ts, checkout.spec.ts) rather than by HTTP method or individual page, which makes reports easier to interpret.The test runner provides CLI flags to filter tests, run in headed or headless mode, and control reporters. Learning a few key commands early makes local debugging smoother.
# Run all tests in headed mode for debugging
npx playwright test --headed
# Run only tests in a specific file
npx playwright test tests/auth.spec.ts
# Run tests by title pattern
npx playwright test --grep "checkout"
# Use trace viewer after a failed run
npx playwright show-trace trace.zip
Common Mistakes
Mistake 1 β Keeping tests and helpers in many random folders
This slows navigation.
β Wrong: Spreading test files across unrelated directories with no clear structure.
β Correct: Use a predictable tests directory and a small number of helper folders.
Mistake 2 β Not using the CLI effectively
Debugging becomes painful.
β Wrong: Always running the entire suite in headless mode when debugging a single scenario.
β Correct: Use filters, headed mode, and trace viewer to focus on specific problems.