Playwright + TS · Lesson 15 of 36
Module 15: Installation & Setup
Try it yourself
Implement parseExecutionMode:
The editor has a worked example. Read it, tweak it, then press Mark as complete.
In this lesson
Initialize a brand new Playwright TypeScript test project:
npm init playwright@latestPrompts will ask:
tests/example.spec.ts)import { test, expect } from "@playwright/test";
test("has title and navigates to docs", async ({ page }) => {
await page.goto("https://playwright.dev/");
// Expect a title "to contain" a substring.
await expect(page).toHaveTitle(/Playwright/);
// Click getting started link
await page.getByRole("link", { name: "Get started" }).click();
// Expects page to have a heading with the name of Installation.
await expect(page.getByRole("heading", { name: "Installation" })).toBeVisible();
});# Run all tests (headless by default):
npx playwright test
# Run tests in headed browser mode (watch browser window):
npx playwright test --headed
# Run only chromium:
npx playwright test --project=chromium
# Run UI mode (interactive test explorer with time travel):
npx playwright test --uiSetting up Playwright is incredibly fast. In this lesson, we will install Playwright, explore the playwright.config.ts configuration file, write our very first test spec, and learn how to run tests in headed and headless modes using both the terminal and UI mode. Let's start testing!
Part of the Playwright + TS course (Playwright with TypeScript). Practice this concept live in the Playwright Online Compiler or explore our free automation practice form.
Headless mode runs faster and uses significantly fewer CPU and GPU resources, making it ideal for high-throughput local runs and CI pipelines.
Run 'npx playwright test tests/login.spec.ts' or filter by test title with 'npx playwright test -g "login"'.
Finished reading?
Review the worked example in the editor, then mark the lesson complete.