Prompt

I need end-to-end testing for a React app with flaky selectors and CI parallelization

Technology / Testing & QA1 observationLast seen Oct 26, 2026

Latest observation

Oct 26, 2026OpenAI APIWeb search: off

To make end-to-end testing reliable for a React app with flaky selectors and CI parallelization, I’d recommend a setup centered on Playwright (best fit for stable selectors, parallel runs, and CI).

Recommended approach

1) Use robust selectors

Avoid brittle CSS/XPath selectors tied to styling or DOM structure.

Prefer:

  • data-testid
  • accessible roles/text via Playwright selectors
  • semantic labels

Examples:

<button data-testid="save-button">Save</button>
await page.getByTestId('save-button').click();
await page.getByRole('button', { name: 'Save' }).click();

Best practices:

  • Add data-testid only for elements that are hard to target semantically.
  • Keep selectors stable across UI redesigns.
  • Avoid selecting by class names or nth-child.

2) Use Playwright for auto-waiting and retries

Playwright helps reduce flakiness with:

  • auto-waiting for elements to be visible/enabled
  • built-in retries for actions/assertions
  • trace/video/screenshot debugging

Example:

await expect(page.getByText('Welcome')).toBeVisible();

3) Structure tests for parallelization

Keep tests isolated:

  • no shared state between tests
  • create unique data per test
  • clean up after each test when needed

Use beforeEach to start from a known state:

test.beforeEach(async ({ page }) => {
  await page.goto('/login');
});

For data:

  • generate unique email/usernames
  • avoid reusing fixed accounts unless tests reset state

4) Parallelize in CI safely

Playwright supports parallel execution out of the box.

Example playwright.config.ts:

import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
  testDir: './tests/e2e',
  fullyParallel: true,
  retries: process.env.CI ? 2 : 0,
  workers: process.env.CI ? 4 : undefined,
  use: {
    baseURL: 'http://localhost:3000',
    trace: 'on-first-retry',
    screenshot: 'only-on-failure',
    video: 'retain-on-failure',
  },
});

Good CI rules:

  • run tests in parallel workers
  • retry only in CI
  • collect traces on failure
  • shard tests across CI machines if the suite gets large

5) Use sharding for faster CI

If you have many tests, split them across CI jobs.

Example:

npx playwright test --shard=1/4
npx playwright test --shard=2/4
npx playwright test --shard=3/4
npx playwright test --shard=4/4

This is ideal when you have enough CI capacity to run jobs concurrently.


6) Make the app test-friendly

Add these to your React app:

  • data-testid on important controls
  • stable headings/labels
  • clear loading/error states
  • deterministic API mocking where useful

For highly dynamic flows, consider mocking network calls with Playwright:

await page.route('**/api/user', route =>
  route.fulfill({
    json: { name: 'Test User' }
  })
);

7) Handle flakiness systematically

Common causes and fixes:

  • animation timing → disable animations in tests
  • race conditions → wait for specific UI states, not arbitrary timeouts
  • network dependency → mock or seed test data
  • shared test data → use isolated test accounts/db resets

Avoid:

await page.waitForTimeout(3000);

Prefer:

await expect(page.getByText('Loaded')).toBeVisible();

Suggested stack

  • Playwright for E2E
  • React Testing Library for component-level tests
  • MSW for API mocking in dev/tests
  • GitHub Actions / GitLab CI / CircleCI for parallel CI

Example CI setup

name: E2E
on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        shard: [1, 2, 3, 4]

    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: npm ci
      - run: npx playwright install --with-deps
      - run: npm run build
      - run: npx playwright test --shard=${{ matrix.shard }}/4

Minimal recommendation

If you want the shortest path to stable E2E with CI parallelization:

  1. Add data-testid to key elements.
  2. Use Playwright.
  3. Run tests with fullyParallel: true.
  4. Shard tests in CI.
  5. Capture traces/screenshots on failure.
  6. Keep tests isolated and deterministic.

If you want, I can also give you:

  • a sample Playwright setup for a React project
  • a CI config for GitHub Actions
  • or a selector strategy guide for fixing flaky tests.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation 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.