Skip to main content

Module 10: E2E Testing

Duration: 2-3 hours | Difficulty: Intermediate

End-to-end tests verify that your application works correctly from the user's perspective, testing complete workflows through the UI.


What You'll Learn

  • Setting up Playwright
  • Writing E2E tests
  • Page Object Model pattern
  • Visual regression testing
  • Handling flaky tests

Module Lessons

LessonTopicDuration
10.1 Playwright SetupInstalling and configuring Playwright30 min
10.2 Writing E2E TestsTesting user workflows45 min
10.3 Page Object ModelOrganizing E2E test code45 min
10.4 Visual TestingScreenshot comparison testing30 min
10.5 Debugging E2EFixing flaky tests30 min

E2E Test Characteristics

Speed:        🐢 Slow (minutes)
Count: 📊 Few (5-20 critical paths)
Scope: 🌐 Complete application
Dependencies: ✅ All real
Cost: 💰💰 Expensive

Example E2E Test

import { test, expect } from '@playwright/test';

test('User can complete checkout', async ({ page }) => {
// Login
await page.goto('/login');
await page.fill('[name="email"]', 'user@example.com');
await page.fill('[name="password"]', 'password');
await page.click('button[type="submit"]');

// Add product to cart
await page.goto('/products');
await page.click('[data-product="laptop"]');
await page.click('button:has-text("Add to Cart")');

// Checkout
await page.goto('/checkout');
await page.fill('[name="cardNumber"]', '4242424242424242');
await page.click('button:has-text("Pay")');

// Verify success
await expect(page.locator('h1')).toHaveText('Order Confirmed!');
});

Prerequisites

Before starting:

  • ✅ Completed Module 09
  • ✅ Working web application
  • ✅ Basic HTML/CSS knowledge

Let's Begin

Ready to test complete user journeys?

Start Lesson 10.1: Playwright Setup