E2E Testing (Playwright)
The E2E framework interacts with the application as a real user would, using Playwright.
Philosophy
Section titled “Philosophy”- User-Centric: Click, type, navigate.
- Efficient Setup: Use
DataFactoryfor state setup, UI for interaction.
Writing Tests
Section titled “Writing Tests”1. Fixtures
Section titled “1. Fixtures”Use the actor and utils fixtures.
import { test, expect } from '@tests/e2e/lib/fixtures';
test('My e2e test', async ({ actor, utils, page }) => { // Test logic});2. Page Objects
Section titled “2. Page Objects”Encapsulate logic in Page Objects.
export class LoginPage extends BasePage { async login(email, pass) { await this.waitForHydration(); await this.fillInteractive('login-email', email); await this.clickInteractive('login-submit'); }}3. Selectors
Section titled “3. Selectors”ALWAYS use data-testid.
await page.getByTestId('login-submit').click();Running Tests
Section titled “Running Tests”# Run all in Dockernpm run test:e2e
# Run interactively (UI Mode)npm run test:e2e:ui