Basic Test Structure in Playwright
From the Playwright cheat sheet ยท Writing Tests ยท verified Jul 2026
Basic Test Structure
Write tests with test blocks, navigation, and assertions
typescript
import { test, expect } from '@playwright/test';
test('has correct title', async ({ page }) => {
await page.goto('/');
await expect(page).toHaveTitle(/My App/);
});
test('navigates to about page', async ({ page }) => {
await page.goto('/');
await page.getByRole('link', { name: 'About' }).click();
await expect(page).toHaveURL('/about');
});๐ก Each test gets a fresh browser context โ no state leaks between tests
โก Playwright auto-waits for elements before interacting โ no manual waits needed
๐ Use test.skip() with a condition to skip tests based on platform or environment
๐ข The page fixture is the most common โ it provides a fresh page for each test
teststructure