Playwright + JS · Lesson 9 of 35

0/35 done

Module 9: JavaScript Project Structure

9. Automation Project Hierarchy & Architecture

14 minlesson

Try it yourself

Implement isRecognizedFolder:

  1. Accept folderName string.
  2. Return true if folderName is in ["tests", "pages", "components", "fixtures", "utils", "data", "config"].

The editor has a worked example. Read it, tweak it, then press Mark as complete.

Standard Playwright JavaScript Project Structure

text
playwright-project/
├── playwright.config.js    # Runner configuration and projects
├── package.json            # Dependencies and npm scripts
│
├── tests/                  # Test specifications (*.spec.js)
│   ├── auth/
│   │   └── login.spec.js
│   └── checkout/
│       └── checkout.spec.js
│
├── pages/                  # Page Object Model classes
│   ├── BasePage.js
│   └── LoginPage.js
│
├── components/             # Reusable UI fragments (Navigation, Modals)
│   └── Header.js
│
├── fixtures/               # Custom test fixtures
│   └── testBase.js
│
├── utils/                  # Reusable helper functions
│   └── stringHelpers.js
│
├── data/                   # Test fixtures and static JSON
│   └── testUsers.json
│
└── config/                 # Environment endpoints and timeouts
    └── envConfig.js

Key Takeaways & Walkthrough Summary

Before writing browser tests, professional QA engineers establish a clean folder hierarchy. In this module, we dissect the standard directory structure: tests, pages, components, fixtures, utils, data, and config. Let's inspect the blueprint!

Part of the Playwright + JS course (Playwright with JavaScript). Practice this concept live in the Playwright Online Compiler or explore our free automation practice form.

Common Doubts & Lesson Q&A

Why separate components/ from pages/?

Components like headers and navigation bars appear across dozens of pages. Keeping them in components/ avoids duplicating locators in every Page Object.

Finished reading?

Review the worked example in the editor, then mark the lesson complete.

JavaScript
Skip