Initialize Playwright with TypeScript
Beginner10 minTrending
Set up Playwright Test from scratch with TypeScript, configure browsers, create your first test, and run it across multiple browsers.
Prerequisites
- -Node.js 18+ installed
- -A web application to test
Steps
1
Initialize Playwright in your project
Run the Playwright installer to scaffold config, example tests, and download browsers.
$ npm init playwright@latest
The installer asks interactive questions. Choose TypeScript, tests/ directory, and yes to GitHub Actions workflow for CI-ready setup.
2
Install specific browsers
Download only the browsers you need to save disk space.
$ npx playwright install chromium firefox
3
Run the example test
Execute the scaffolded tests to verify the setup works.
$ npx playwright test
4
Run tests with the UI mode
Open the interactive test runner for visual debugging.
$ npx playwright test --ui
UI mode provides a time-travel debugger, live locator picker, and watch mode for rapid test development.
5
View the HTML report
Open the built-in test report to review results and traces.
$ npx playwright show-report
Full Script
FAQ
Discussion
Loading comments...