Install Tools
Before writing any UI test, you need Node, an editor with the Playwright extension, and a Playwright project with browsers downloaded. This page gets you from nothing to a green test run.
Note: This track is written against Playwright 1.63. Commands are checked on macOS. Windows equivalents are noted where they differ.
Required Tools
Node.js
Playwright Test runs on Node. Use the current LTS release (Node 20 or newer).
Steps:
- Download the LTS installer from https://nodejs.org/, or install with a package manager:
# macOSbrew install node# Windowswinget install OpenJS.NodeJS.LTS
- Open a new terminal
Verify: node --version prints v20 or higher, and npm --version prints a version.
Visual Studio Code + Playwright Extension
You can use any editor, but the official VS Code extension gives you a test explorer, a recorder, locator picking and a debugger in one place. The rest of this track assumes you have it.
Steps:
- Install VS Code from https://code.visualstudio.com/
- Open the Extensions view and search for Playwright Test for VSCode (publisher: Microsoft)
- Install it. A Testing icon (a flask) appears in the left sidebar
Verify: The Testing sidebar shows a Playwright section once you open a project that has a playwright.config.ts.
Playwright Project
Playwright is installed per project, not globally. The init command creates the project layout, installs the test runner and downloads the browsers.
Steps:
-
Create a folder for your tests and open a terminal in it
-
Run the init command:
npm init playwright@latest -
Answer the prompts. My choices:
- TypeScript or JavaScript: TypeScript
- Where to put your end-to-end tests:
tests - Add a GitHub Actions workflow: Yes (you get a working CI file for free, see Section 10 - Running in CI)
- Install Playwright browsers: Yes
To skip the prompts, pass the answers as flags:
npm init playwright@latest -- --quiet --browser=chromium --gha --lang=ts -
Look at what was created:
File What it is playwright.config.tsTest runner configuration: browsers, timeouts, reporters, base URL tests/example.spec.tsA sample test against playwright.dev .github/workflows/playwright.ymlGitHub Actions workflow (if you said yes) package.jsonHas @playwright/testas a dev dependency -
Run the sample test:
npx playwright test -
Open the HTML report:
npx playwright show-report
Verify: The terminal prints 2 passed and the report opens in your browser with two green tests.
Tip: The browsers are downloaded to a cache folder outside your project (
~/Library/Caches/ms-playwrighton Mac,%USERPROFILE%\AppData\Local\ms-playwrighton Windows).npx playwright install --listshows what is installed. Every Playwright version pins its own browser builds, so after upgrading runnpx playwright installagain.
Important: The
npxprefix runs the Playwright that is installed in this project. A global install is not needed and only causes version confusion.
Optional Tools
Playwright Test Agents
Since 1.56, Playwright ships agent definitions (planner, generator, healer) for AI coding tools such as Claude Code and VS Code Copilot. They can draft a test plan from a running app, generate spec files from that plan, and try to repair failing tests.
npx playwright init-agents --loop=claude
Other loop options: vscode, codex, opencode. Re-run this after upgrading Playwright so the agent definitions pick up new tools. I treat these as an assistant, not a replacement for understanding the locators and assertions in Section 5.
ESLint
Optional, but the one rule worth having is @typescript-eslint/no-floating-promises. A forgotten await in a Playwright test is the most common cause of a test that passes when it should fail. See Section 6 - Test Structure.
The Sample Project
The code shown in this track lives in a small runnable project inside the knowledge base: playwright/sample/. Every page shows the relevant file. Clone the repo, then:
cd playwright/sample
npm ci
npx playwright install chromium
npx playwright test
Verify: 9 passed.