Prompt

How do I set up end-to-end testing for a web app

Technology / Testing & QA2 observationsLast seen Nov 24, 2026

Latest observation

Nov 24, 2026OpenAI APIWeb search: off

End-to-end (E2E) testing checks your app the way a real user would: opening the browser, clicking around, filling forms, and verifying the full flow works.

1) Pick an E2E tool

Popular choices:

  • Playwright — modern, fast, great cross-browser support
  • Cypress — very popular, easy to start with
  • Selenium — older, very broad ecosystem
  • WebdriverIO — flexible, good for larger setups

If you’re starting fresh, Playwright is often the best default.

2) Install the test runner

Example with Playwright:

npm init playwright@latest

This sets up:

  • test framework
  • browser binaries
  • sample tests
  • config file

3) Make your app testable

Good E2E tests depend on stable selectors and predictable behavior.

Add test-friendly selectors

Use attributes like:

<button data-testid="login-button">Log in</button>

Then target them in tests instead of fragile CSS classes or text that changes often.

Keep environments consistent

Use separate configs for:

  • local dev
  • staging
  • CI

E2E tests should usually run against a clean, dedicated test environment.

4) Create realistic test data

Your tests may need:

  • seeded users
  • sample orders/posts/projects
  • known passwords
  • mocked payment or email services

Ways to handle this:

  • seed the database before tests
  • use API calls to create test fixtures
  • reset the database between test runs

5) Write your first test

Example in Playwright:

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

test('user can log in', async ({ page }) => {
  await page.goto('http://localhost:3000/login');
  await page.getByTestId('email').fill('test@example.com');
  await page.getByTestId('password').fill('password123');
  await page.getByTestId('login-button').click();

  await expect(page).toHaveURL(/dashboard/);
  await expect(page.getByText('Welcome')).toBeVisible();
});

6) Run tests locally

Typical workflow:

  • start your app
  • run the E2E suite
  • fix flaky tests before adding more

Example:

npm run dev
npx playwright test

7) Add tests to CI

Run E2E tests automatically on:

  • pull requests
  • merges to main
  • scheduled nightly builds

Example CI steps:

  1. install dependencies
  2. start app/backend
  3. wait until services are ready
  4. run E2E tests
  5. collect screenshots/videos on failure

8) Handle external dependencies

E2E tests often fail because of:

  • flaky third-party APIs
  • email/SMS providers
  • payment gateways
  • network timing issues

Best practice:

  • mock external services in test environments
  • use sandbox modes
  • isolate what you control

9) Keep tests stable

To reduce flakiness:

  • avoid arbitrary sleep calls
  • wait for specific UI conditions
  • use reliable locators
  • keep tests independent
  • don’t test too many things in one test

10) Start small

Begin with a few critical user journeys:

  • sign up
  • log in
  • create/edit/delete a key object
  • checkout or submit form
  • logout

Then expand over time.


Recommended minimal setup

If you want a simple, practical stack:

  • Playwright
  • data-testid selectors
  • seeded staging/test database
  • CI integration with GitHub Actions

If you want, I can give you:

  1. a Playwright setup for React/Next.js/Vue
  2. a Cypress setup
  3. a sample GitHub Actions workflow
  4. a best-practice folder structure for E2E tests

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (2 observations for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.