Course contentsShow
← React
Lesson 2191 of 2,39648. End-to-End TestingFree lesson

Balance: Enough E2E Coverage Without Fragility

Aim for 10-20 robust E2E tests covering critical paths; avoid brittle tests that break with every UI change.

Balance: Enough E2E Coverage Without Fragility

You'll learn: How to choose the right number and type of E2E tests so you get confidence without creating a maintenance nightmare.

The Goldilocks Problem

E2E tests are powerful but expensive. Too few, and critical bugs slip through. Too many, and your test suite becomes a brittle, slow-moving beast that breaks with every UI tweak. The goal is finding the "just right" balance.

The 10-20 Rule of Thumb

Aim for 10-20 robust E2E tests that cover your application's critical paths:

  • Authentication flow: Login, logout, session persistence
  • Core business transactions: Checkout, payment, order confirmation
  • Critical user journeys: Signup → onboarding → first success moment
  • High-risk features: Admin actions, data deletion, permissions

These tests should survive UI refactors. If renaming a CSS class breaks ten tests, you've tested too much implementation.

Building Robust Tests

Focus on what users actually see and do:

  • Use semantic selectors (roles, labels) that match user perception
  • Avoid brittle selectors like class names or deep DOM paths
  • Test outcomes, not intermediate states
  • Let Playwright's auto-waiting handle timing issues

Think of E2E tests as smoke detectors, not microscopes. They should catch fires (broken critical flows), not dust particles (minor UI inconsistencies).

When to Stop Adding E2E Tests

If a scenario is covered by unit or integration tests, you probably don't need E2E coverage. Edge cases, validation logic, and component states belong in faster test layers. E2E tests are for proving the whole system works together for real users.

Key Takeaway: Maintain 10-20 E2E tests covering critical user journeys, using resilient selectors that survive UI changes. Let unit and integration tests handle the details.