Playwright has a single command that sets up everything. No googling "how to configure Playwright." No copy-pasting from Stack Overflow. One command and you are ready to write tests.
# Create a new folder for your project
mkdir my-playwright-project
cd my-playwright-project
# Initialize Playwright -- this is the magic command
npm init playwright@latestThe init command asks you a few questions. Here is what to pick:
| Question | What to Choose | Why |
|---|---|---|
| TypeScript or JavaScript? | TypeScript | Type safety catches bugs before you run the test. Always TypeScript. |
| Where to put tests? | tests | Default folder. Keep it simple. |
| Add a GitHub Actions workflow? | Yes | Free CI/CD setup. You can always remove it later. |
| Install Playwright browsers? | Yes | Downloads Chromium, Firefox, and WebKit. About 400 MB total. |
After the command finishes, your project folder looks like this. Every file has a purpose -- no bloat.
my-playwright-project/
├── playwright.config.ts # Configuration -- browsers, timeouts, retries
├── package.json # Dependencies (just @playwright/test)
├── package-lock.json # Locked dependency versions
├── tests/
│ └── example.spec.ts # Sample test to prove setup works
├── tests-examples/
│ └── demo-todo-app.spec.ts # Full-featured example (great for learning)
├── .github/
│ └── workflows/
│ └── playwright.yml # GitHub Actions CI config
└── node_modules/ # Dependencies (including browser binaries)Add node_modules/ and test-results/ to your .gitignore file. Browser binaries are 400 MB -- you do not want that in your Git history. The test-results folder contains screenshots and traces from failed tests.
Run the sample test immediately after setup: npx playwright test. If it passes, your setup is good. If it fails, fix it now before writing your own tests. Never build on a broken foundation.
Key Point: npm init playwright@latest is the only command you need to memorize. It creates the config, sample tests, CI pipeline, and downloads browsers. Zero manual setup.
Key Point: One command creates everything: config, tests folder, sample tests, CI pipeline, and browser binaries.