One npx playwright test that exits 0
The first success is one npx playwright test that exits 0, not a finished install.
A first Playwright run counts when one npx playwright test exits 0, not when the install finishes. The official sample opens playwright.dev. Write the words the title must contain in a wbstorm room first.
On playwright.dev/docs/intro the result you want is headless, all three browsers passed, process exit 0. The scaffold file is tests/example.spec.ts.
Leave the sample alone until it is green
Node is off the list
The intro names the latest 22.x, 24.x, or 26.x. macOS is 14 (Sonoma) or later. The wrong runtime stops init before any test runs.
Browser binaries were skipped
Install Playwright browsers defaults to yes. No means there is no Chromium, Firefox, or WebKit to launch, and the command will not exit 0.
You edit in your own URL first
The sample opens https://playwright.dev/, expects a title matching Playwright, clicks Get started, and expects a heading named Installation. Get exit 0 on that file, then change the URL.
The official path to exit 0
- 1
Check the system line
Node.js: latest 22.x, 24.x, or 26.x. Windows 11+, Windows Server 2019+, or WSL. macOS 14+. Debian 12/13, Ubuntu 22.04 / 24.04 / 26.04 (x86-64 or arm64).
- 2
Init without overwriting tests
Run
npm init playwright@latest. Confirm TypeScript or JavaScript, the tests folder (defaulttests, ore2eif tests exists), a GitHub Actions workflow, and browser install (default yes). A later run does not overwrite existing tests. Yarn:yarn create playwright. pnpm:pnpm create playwright. - 3
See what it wrote
playwright.config.tsholds browsers, timeouts, retries, projects, and reporters.tests/example.spec.tsis the minimal example. An existing project only gains dependencies in the current package.json. - 4
Run it and read the exit code
npx playwright test. Headless, parallel, Chromium plus Firefox plus WebKit. Exit code 0 only when every project passes. One browser:npx playwright test --project=chromium. Show the window with--headed. One file:npx playwright test tests/example.spec.ts.
| Command | What the docs say | First run |
|---|---|---|
| npx playwright test | Headless, three browsers, parallel | Exit 0 is the pass |
| --project=chromium | One project only | Narrow a red run |
| show-report | Auto-opens only on failure | Open it yourself if green |
The two assertions in the sample
import { test, expect } from '@playwright/test';
test('has title', async ({ page }) => {
await page.goto('https://playwright.dev/');
await expect(page).toHaveTitle(/Playwright/);
});
test('get started link', async ({ page }) => {
await page.goto('https://playwright.dev/');
await page.getByRole('link', { name: 'Get started' }).click();
await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible();
});Actions wait until the element is actionable. Async assertions wait until the condition is met. Skip the manual sleep. Each test gets a new Browser Context, a fresh browser profile. npx playwright --version prints what you installed. The intro does not pin one package version.
Put the expected title in a room first: send a room ID and write the required words on the whiteboard. wbstorm does not run Playwright. The test stays in your repo.
The exit code is not 0?
See which project failed in the terminal. The HTML report opens on its own. If browsers were skipped, run init again and accept the install, or run npx playwright install --with-deps from the update section.
Can I run only Chromium?
Yes. npx playwright test --project=chromium. The default config still runs all three. The first full pass is the command without a project flag.
Why does the sample open playwright.dev?
That is the first test in writing-tests: title matches /Playwright/, then a heading named Installation after clicking Get started. Change the URL after the first exit 0.
Should I add waitForTimeout?
No. Docs: actions wait for actionability, and async matchers wait until the expectation is met. A manual wait is not how the first test goes green.