English · Node.js
Appearance
English · Node.js
Appearance
Playwright Test is an end-to-end test framework for modern web apps. It bundles test runner, assertions, isolation, parallelization and rich tooling. Playwright supports Chromium, WebKit and Firefox on Windows, Linux and macOS, locally or in CI, headless or headed, with native mobile emulation for Chrome (Android) and Mobile Safari.
You will learn
Get started by installing Playwright using one of the following methods.
The command below either initializes a new project or adds Playwright to an existing one.
npm init playwright@latestyarn create playwrightpnpm create playwrightWhen prompted, choose / confirm:
tests, or e2e if tests already exists)You can re-run the command later; it does not overwrite existing tests.
You can also create and run tests with the VS Code Extension.
Playwright downloads required browser binaries and creates the scaffold below.
playwright.config.ts # Test configuration
package.json
package-lock.json # Or yarn.lock / pnpm-lock.yaml
tests/
example.spec.ts # Minimal example testThe playwright.config centralizes configuration: target browsers, timeouts, retries, projects, reporters and more. In existing projects dependencies are added to your current package.json.
tests/ contains a minimal starter test.
By default tests run headless in parallel across Chromium, Firefox and WebKit (configurable in playwright.config). Output and aggregated results display in the terminal.
npx playwright testyarn playwright testpnpm exec playwright test
Tips:
--headed.--project=chromium.npx playwright test tests/example.spec.ts.--ui.See Running Tests for details on filtering, headed mode, sharding and retries.
After a test run, the HTML Reporter provides a dashboard filterable by the browser, passed, failed, skipped, flaky and more. Click a test to inspect errors, attachments and steps. It auto-opens only when failures occur; open manually with the command below.
npx playwright show-reportyarn playwright show-reportpnpm exec playwright show-report
Run tests with UI Mode for watch mode, live step view, time travel debugging and more.
npx playwright test --uiyarn playwright test --uipnpm exec playwright test --ui
See the detailed guide on UI Mode for watch filters, step details and trace integration.
Update Playwright and download new browser binaries and their dependencies:
npm install -D @playwright/test@latest
npx playwright install --with-depsyarn add --dev @playwright/test@latest
yarn playwright install --with-depspnpm install --save-dev @playwright/test@latest
pnpm exec playwright install --with-depsCheck your installed version:
npx playwright --versionyarn playwright --versionpnpm exec playwright --version