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.
Tap a title to open that way of learning. Use as many as you need — then take the lesson quiz below.
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.
The course lab's real setup (Node v24, npm 10), exactly as performed — transcript saved with the project.
$ npm init -y — creates package.json, the project's manifest.
$ npm install -D @playwright/test → "added 3 packages". Playwright Test is the runner: it executes tests and collects evidence.
$ npx playwright --version → Version 1.65.0.
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.
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.
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.
One map of the lesson: five steps from an empty folder to a suite whose failures you can trust.
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'
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.
The program that executes tests and collects their evidence — here, Playwright Test.
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…
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:
| The weak way | The 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. |
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?