0Pricing
Sveltejs Academy · Lesson

Writing Page Interaction Tests

Click, fill forms, and assert DOM state using Playwright's powerful API.

Basic Test

Each test imports test and expect from Playwright.

import { test, expect } from "@playwright/test";
test("homepage", async ({ page }) => {
  await page.goto("/");
  await expect(page).toHaveTitle(/My App/);
});

Navigation

Use page.goto(url) to visit pages and page.click() to navigate via clicks.

All lessons in this course

  1. Playwright Setup in SvelteKit
  2. Writing Page Interaction Tests
  3. Testing Forms and Navigation
  4. CI Integration
← Back to Sveltejs Academy