Prompt

How do I automate regression tests for a frontend app in CI?

Technology / Testing & QA1 observationLast seen Oct 26, 2026

Latest observation

Oct 26, 2026OpenAI APIWeb search: off

A practical way to automate frontend regression tests in CI is to split them into a few layers and run the right ones on every change.

1) Use a test pyramid

Typical setup:

  • Unit tests: fast, run on every commit
  • Component tests: render UI pieces in isolation
  • End-to-end (E2E) tests: verify critical user flows in a real browser
  • Visual regression tests: catch layout/style changes by comparing screenshots

For frontend regression, the most valuable CI checks are usually:

  • unit/component tests for broad coverage
  • a small number of E2E tests for critical paths
  • visual tests for important pages/components

2) Pick the right tools

Common choices:

  • Unit/component: Jest, Vitest, React Testing Library, Cypress Component Testing, Playwright Component Tests
  • E2E: Playwright or Cypress
  • Visual regression: Playwright screenshots, Percy, Chromatic, Applitools

If you want one tool that covers a lot, Playwright is a strong choice because it handles E2E well and can also do screenshot-based regression testing.

3) Make tests deterministic

Regression tests fail in CI mainly because they’re flaky. Reduce that by:

  • using fixed test data/mocks
  • isolating external APIs
  • resetting DB/state before tests
  • avoiding time-sensitive assertions unless you control time
  • waiting for UI states instead of arbitrary sleeps
  • setting consistent viewport, locale, timezone, and fonts
  • disabling animations in tests

4) Add a CI pipeline

A typical CI workflow:

  1. Install dependencies
  2. Lint and type-check
  3. Run unit/component tests
  4. Build the app
  5. Start the app or preview environment
  6. Run E2E tests
  7. Run visual regression checks
  8. Upload artifacts: screenshots, videos, traces, reports

5) Example CI flow

Example with GitHub Actions:

name: frontend-ci

on:
  pull_request:
  push:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - name: Use Node
        uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: npm

      - name: Install dependencies
        run: npm ci

      - name: Lint
        run: npm run lint

      - name: Type check
        run: npm run typecheck

      - name: Unit tests
        run: npm test -- --ci

      - name: Build
        run: npm run build

      - name: Install Playwright browsers
        run: npx playwright install --with-deps

      - name: Run E2E tests
        run: npm run test:e2e

      - name: Upload Playwright report
        if: failure()
        uses: actions/upload-artifact@v4
        with:
          name: playwright-report
          path: playwright-report/

6) Add visual regression

If using Playwright, you can capture screenshots and compare them in CI.

Example test:

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

test('home page matches screenshot', async ({ page }) => {
  await page.goto('http://localhost:3000');
  await expect(page).toHaveScreenshot('home.png');
});

Then:

  • run once to generate baseline screenshots
  • store baselines in git or a dedicated service
  • fail CI if screenshots differ unexpectedly

For larger teams, tools like Percy or Chromatic make review of visual diffs easier.

7) Run only relevant tests when possible

To keep CI fast:

  • run all checks on main branches
  • on PRs, run only tests affected by changed files if your setup supports it
  • split E2E tests into shards or parallel jobs
  • run smoke tests first, full suite later

8) Make failures easy to debug

Have CI save:

  • screenshots
  • video recordings
  • browser traces
  • HTML test reports
  • logs from backend mocks or test servers

Playwright is especially good here with trace viewer support.

9) Keep the test suite healthy

Maintain tests by:

  • removing brittle selectors
  • preferring roles/labels over CSS selectors
  • keeping E2E tests focused on user journeys
  • reviewing flaky tests immediately
  • updating baselines intentionally for visual diffs

Recommended setup

If you’re starting fresh:

  • Vitest + React Testing Library for unit/component tests
  • Playwright for E2E and visual regression
  • GitHub Actions or your CI provider to run everything on pull requests

If you want, I can give you:

  1. a complete GitHub Actions config,
  2. a Playwright setup for regression tests,
  3. or a step-by-step strategy for React/Vue/Angular specifically.

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.