Playwright + TS · Lesson 13 of 36
Module 13: Automation Project Structure
Try it yourself
Define the StandardFolder union type and isStandardFolder type guard:
The editor has a worked example. Read it, tweak it, then press Mark as complete.
A chaotic test repository with tests, locators, and configs mixed together in the root directory quickly collapses under maintenance debt. Here is the industry standard structure:
playwright-project/
├── playwright.config.ts # Central Playwright runner settings
├── tsconfig.json # TypeScript compilation and path aliases
├── package.json # Dependencies and npm scripts
│
├── tests/ # Spec files (.spec.ts) organized by feature/domain
│ ├── auth/
│ │ ├── login.spec.ts
│ │ └── reset-password.spec.ts
│ └── checkout/
│ └── checkout-flow.spec.ts
│
├── pages/ # Page Object Model classes (business workflows)
│ ├── BasePage.ts
│ ├── LoginPage.ts
│ └── DashboardPage.ts
│
├── components/ # Reusable UI fragments (Navigation, Modals, Tables)
│ ├── HeaderComponent.ts
│ └── NotificationToast.ts
│
├── fixtures/ # Custom test fixtures (injected page objects, states)
│ └── test-base.ts
│
├── utils/ # Non-browser utilities (date formatting, string helpers)
│ └── string-utils.ts
│
├── data/ # Test fixtures, mock payloads, JSON files
│ ├── users.json
│ └── orders.json
│
├── types/ # Shared TypeScript interfaces and type definitions
│ ├── user.types.ts
│ └── api.types.ts
│
└── config/ # Environment endpoints and credentials
└── environment.config.ts*.spec.ts). Tests should read like plain English user stories and contain minimal raw locators.Before diving into browser actions, let's explore professional automation project structure. In this lesson, we will tour a clean industry-standard Playwright repository, breaking down the purpose of tests, pages, components, fixtures, utils, data, types, and config directories. Let's explore the blueprint!
Part of the Playwright + TS course (Playwright with TypeScript). Practice this concept live in the Playwright Online Compiler or explore our free automation practice form.
A navigation header or modal dialog appears on dozens of pages. Creating a single HeaderComponent avoids duplicating navigation locators in every single Page Object.
No. Keeping data/ centralized allows multiple test suites to reuse identical mock payloads and prevents test specs from becoming bloated with raw JSON strings.
Finished reading?
Review the worked example in the editor, then mark the lesson complete.