LESSON VIEW
PQA-09 · LEVEL 3 AUTOMATION & RELEASE · PRACTICAL QA

Set Up a Playwright Project, Step by Step

Objective: Create a real Playwright test project from an empty folder — install, config with an environment-switched base URL, and a first test translated line-for-line from a test case — and read its failure on a buggy build correctly.

⏱ ≈2.5 h full lesson · You will type real commands · English edition — Español · العربية · বাংলা in translation

🧽 The practice business: FreshNest Home Cleaning — a fictional local cleaning company (owner: Maya Torres) invented for this course. Every example and exercise uses FreshNest, so you learn on a complete, realistic business without ever touching a real one.

2 of 11 modes explored

Ways to learn this lesson

Tap a title to open that way of learning. Use as many as you need — then take the lesson quiz below.

📖Read
The full lesson, in order
~30 min›

Automation is not a different subject from the rest of this course — it is test cases, executed by a machine. The setup exists to make three things true: the same checks run the same way every time; a failure produces evidence a human can read (which case, expected versus actual, a screenshot, a video); and pointing the suite at a different build is a one-line change, not an edit in twenty files.

The project in this lesson is the course's real lab project, and its first run does the most valuable thing a suite can do: fail, correctly, on the buggy practice build — naming exactly the cases from your test-case document. Three failures, each one a seeded defect you already found manually in earlier lessons. A suite that passes on a buggy build would be the worrying result: it would mean your assertions describe the screen instead of the requirement.

Choose what to automate by one test: can the expected result be stated exactly, and will this check be re-run many times? Pricing math and validation rules pass both. One-off explorations and "does this feel right" judgments stay manual — that was exploratory testing, and it stays human.

⚡Key Points
The whole lesson in 5 bullets
~5 min›
  • Automation = test cases executed by a machine. Nothing about the discipline changes.
  • Config carries base URL, timeouts, video, and screenshots — set once, benefit every run.
  • Base URL from an environment variable: the same suite tests any build; retest = rerun.
  • A correct suite FAILS on the buggy build, naming the defect cases.
  • Automate stable, rule-based, exactly-statable checks first.
🪜Worked Example
Watch one task done step by step
~12 min›

The course lab's real setup (Node v24, npm 10), exactly as performed — transcript saved with the project.

1 · Create and initialise

$ npm init -y — creates package.json, the project's manifest.

2 · Install the runner

$ npm install -D @playwright/test → "added 3 packages". Playwright Test is the runner: it executes tests and collects evidence.

3 · Confirm

$ npx playwright --version → Version 1.65.0.

4 · The config (complete file)

playwright.config.ts: testDir './tests', timeout 30s, reporter 'list', use: { baseURL: process.env.SITE_URL || 'http://localhost:8931', video: 'on', screenshot: 'only-on-failure' }. The environment-variable base URL is the one design decision to copy.

5 · The first test = TC-FN-PRC-001, translated

page.goto('/') → select 'deep' → select '2' → expect the estimate to have text '$210'. Steps became actions; the expected result became the assertion. Nothing else changed.

6 · The first run — against the buggy build

3 failed: TC-FN-PRC-001 (Deep price), TC-FN-VAL-001 (phone), TC-FN-VAL-002 (success on error). 3 passed. Every failure is correct: each names a real defect.

🗺️Visual Map
The idea as a diagram
~6 min›
Test cases, run by machinenpm init -ypackage.jsonInstall @playwright/testThe runner is readyplaywright.config.tsBase URL + evidence set oncetests/*.spec.tsCases, translated line-for-linenpx playwright testVerdicts + artifactsCorrect failures on the buggy buildtranslates toproducesleaves behindTest caseTest codeRunEvidence

One map of the lesson: five steps from an empty folder to a suite whose failures you can trust.

🧪Hands-On Lab
Do it yourself, then reveal the key
~20 min›

Match each command or file to what it does.

1. npm init -y

2. npm install -D @playwright/test

3. npx playwright --version

4. baseURL: process.env.SITE_URL || 'http://localhost:8931'

5. screenshot: 'only-on-failure'

🎧Listen
Hear it narrated in your language
~4 min›

Setting up is five honest steps. Initialise the project. Install the Playwright test runner. Confirm the version prints. Write one config file that says where the site lives and turns on video and failure screenshots. Then translate your first test case, line for line: the steps become actions, the expected result becomes the assertion. Run it against the buggy practice build and it fails, correctly, naming the price defect. That failure is the suite working. If it had passed on a build you know is broken, your assertions would be describing the screen instead of the requirement. Same discipline as manual testing. The machine just never gets bored.

🃏Flashcards
Key terms, flip to recall
~6 min›
Test runner
Tap the card to flip it

The program that executes tests and collects their evidence — here, Playwright Test.

1/5
🎭Scenario
A story decision — you be the owner
~7 min›

A teammate's suite has the staging URL typed inside all 14 test files. A release candidate arrives at a new address. The professional move is…

🗣️Teach-Back
Explain it in your own words
~10 min›

Explain to a friend: why is a failing first run on the buggy build a success for the project? Use TC-FN-PRC-001 in your answer.

Now check yourself honestly:

⚖️Before / After
Weak way vs strong way, side by side
~6 min›
The weak wayThe strong way
No video, no screenshots — failures say "it broke" and nothing else.

URLs and selectors typed inside every test.

First run on the buggy build fails on exactly the defect cases.

One config: environment-switched baseURL, video on, screenshots on failure.

📋Job Aid
A checklist to use at work
~3 min›

📝 Lesson Quiz — Check Yourself

1. Why does the config read the base URL from an environment variable?

2. Your new suite passes 6/6 on the buggy practice build. Your reaction?

3. Which check belongs in automation first?

Score: 0 / 3