E2E

Term side of the Card.
Topic: Testing
Unit title: E2E
Categories: Approach
Explanation side of the Card

Explanation: The type of software testing that simulates real user behavior and verifies that all parts of the application work together as expected. It tests the entire flow from user input to the final result.

Example

Wrongts
await page.click('.btn-primary');
await page.waitForTimeout(3000);
expect(await page.textContent('.msg')).toBe('Saved');
Rightts
await page.getByRole('button', { name: 'Save' }).click();
await expect(page.getByRole('status')).toHaveText('Saved');

Role locators match what users see, and expect retries until the text appears instead of sleeping a fixed time.

Common mistakes

  • Flaky tests caused by fixed sleeps instead of waiting for the UI state.
  • Selectors that break when a class name changes.
  • Covering every edge case with E2E tests, which makes the suite slow.

Key points

  • Elements are found by role, label or text, such as getByRole(), not by fragile CSS classes.
  • The test waits with auto-retrying assertions, not fixed timeouts like waitForTimeout(3000).
  • Each test creates its own data or user and does not depend on other tests.
  • Login state is set up once and reused instead of logging in through the UI in every test.

Interview questions

How many E2E tests should a project have?

A small number covering the most important user flows, like sign up and checkout. Put detailed logic checks in unit and integration tests.

Why are my E2E tests flaky?

Common causes are fixed waits, shared test data, animations and network calls to real third-party services. Use auto-waiting and isolated data.

Should E2E tests run against production?

Usually they run against a staging or preview environment. A few safe smoke checks can also run against production after deploy.

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy