Prompt

How do I set up a visual browser testing tool for catching responsive layout issues across common screen sizes?

Technology · Testing & QA / Testing qa1 observationLast seen Jul 17, 2026

Latest observation

Jul 17, 2026 · OpenAI APIWeb search: off

A good way to catch responsive layout issues is to use a visual regression testing tool that can open your site at multiple viewport sizes, take screenshots, and compare them against a baseline.

Good options

  • Playwright: best modern choice for browser automation + screenshots
  • Cypress + Percy: good if you already use Cypress
  • Applitools: commercial, strong AI-based visual diffs
  • Chromatic: great for Storybook component testing

If you want a straightforward open-source setup, Playwright is a strong default.


Recommended setup with Playwright

1) Install Playwright

npm init playwright@latest

Or add it to an existing project:

npm install -D @playwright/test
npx playwright install

2) Define common viewport sizes

Typical breakpoints to test:

  • Mobile: 375x667
  • Small mobile: 320x568
  • Tablet: 768x1024
  • Laptop: 1366x768
  • Desktop: 1440x900
  • Large desktop: 1920x1080

You can either test full-page screenshots or only key pages/components.


3) Write visual snapshot tests

Example:

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

const viewports = [
  { name: 'mobile', width: 375, height: 667 },
  { name: 'tablet', width: 768, height: 1024 },
  { name: 'desktop', width: 1440, height: 900 },
];

for (const vp of viewports) {
  test(`homepage looks correct on ${vp.name}`, async ({ page }) => {
    await page.setViewportSize({ width: vp.width, height: vp.height });
    await page.goto('http://localhost:3000');

    // Wait for layout/content to settle
    await page.waitForLoadState('networkidle');

    // Compare against baseline
    await expect(page).toHaveScreenshot(`homepage-${vp.name}.png`);
  });
}

This will:

  • capture screenshots at each size
  • compare them to saved baselines
  • fail if layout changes unexpectedly

4) Add baseline image updates

When you intentionally change the UI:

npx playwright test --update-snapshots

That refreshes the stored reference screenshots.


5) Run in CI

In your CI pipeline, run the tests on every PR:

npx playwright test

Make sure the environment is stable:

  • fixed browser version
  • consistent fonts if possible
  • deterministic test data
  • disable animations

Reduce flaky visual diffs

To avoid false positives:

  • Disable animations/transitions
  • Mock dynamic data or use a stable test environment
  • Use consistent fonts
  • Mask timestamps, ads, avatars, and other dynamic regions
  • Test specific pages and components, not just the whole site

Example to disable animations:

await page.addStyleTag({
  content: `
    *, *::before, *::after {
      animation: none !important;
      transition: none !important;
    }
  `,
});

Better for component libraries: Storybook + visual testing

If you’re testing UI components rather than full pages:

  1. Build components in Storybook
  2. Connect it to:
    • Chromatic
    • or Playwright screenshots

This is ideal for catching responsive issues in reusable components.


Example CI strategy

A solid workflow:

  1. Run unit tests
  2. Run Playwright visual tests at key breakpoints
  3. Review screenshot diffs in PR
  4. Approve baseline updates only when changes are expected

If you want the simplest “works out of the box” approach

  • For full app pages: Playwright
  • For design-system components: Storybook + Chromatic

If you want, I can give you:

  1. a copy-paste Playwright config for responsive screenshot tests, or
  2. a Storybook + Chromatic setup for component-level visual regression.

Observation history

Unlock observation history

Create a free Obsurfable account to unlock historical responses, model comparisons, and deeper brand intelligence.

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, and Meta AI.