Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
FREEDOM251

Freedom251 › Blog › CI/CD

How to Set Up Screenshot Tests for a React Website in an Indian CI Pipeline

By Freedom251 Team · · 7 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Playwright Test to capture a React page and compare it with a committed reference image on every CI run. The commands are the same for an Indian team as for any other location; the key is to generate and check screenshots in a consistent browser and operating-system environment. This guide uses GitHub Actions on Linux as a concrete example, while noting what to adapt for your app and pipeline.

What you need for repeatable screenshot tests

A visual test checks whether a rendered page differs from an approved screenshot. Playwright Test provides the toHaveScreenshot() assertion: the first run creates a reference image, and subsequent runs compare against it. Keep the test, reference images, and package lockfile in version control so changes can be reviewed alongside code.

As an Amazon Associate I earn from qualifying purchases.

  • A React app that can be started in the test environment, plus any required backend or test data.
  • Playwright Test installed as a project dependency and locked through your package manager.
  • A CI job with the matching browser binaries and required operating-system dependencies.
  • A policy for reviewing screenshot changes and protecting reports, traces, and logs.

Playwright’s official visual comparisons guide explains screenshot assertions and why reference images are tied to the rendering environment. Its CI guide documents browser installation, Linux dependencies, containers, workers, sharding, and caching. This article uses npm and GitHub Actions for illustration; adapt commands if your project uses another package manager or CI provider.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Add a visual test to the React project

Install Playwright Test using the package manager already used by the repository, following the current Playwright installation instructions. Commit the resulting dependency lockfile. Then create a test such as tests/home.spec.ts:

#1 Best Overall
CanaKit Raspberry Pi 5 Starter Kit PRO - Turbine Black (128GB Edition) (8GB RAM)
  • Includes Raspberry Pi 5 with 2.4Ghz 64-bit quad-core CPU (8GB RAM)
  • Includes 128GB Micro SD Card pre-loaded with 64-bit Raspberry Pi OS, USB MicroSD Card Reader
  • CanaKit Turbine Black Case for the Raspberry Pi 5
  • CanaKit Low Noise Bearing System Fan
  • Mega Heat Sink - Black Anodized
import { test, expect } from '@playwright/test';

test('home page visual baseline', async ({ page }) => {
  await page.goto('/');
  await expect(page).toHaveScreenshot('home.png');
});

The first run may create the snapshot rather than compare against an existing approved image. Inspect the image, confirm it represents the intended state, and commit it. Later runs compare new captures with that reference. Choose a meaningful route and state: a landing page, navigation menu, key form, or purchase flow is often more useful than trying to snapshot every route immediately.

Start the app through Playwright configuration

Configure Playwright to start the app and wait for its readiness URL. The following example assumes a Vite-style preview server on port 4173; it is an example, not a required React command. Replace the command, host, port, environment variables, and readiness URL with those for your app.

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

export default defineConfig({
  workers: process.env.CI ? 1 : undefined,
  webServer: {
    command: 'npm run preview -- --host 0.0.0.0',
    url: 'http://127.0.0.1:4173',
    reuseExistingServer: !process.env.CI,
  },
  use: {
    baseURL: 'http://127.0.0.1:4173',
  },
});

With baseURL set, page.goto('/') resolves to the local app. If the test requires a backend, configure the additional service as well; Playwright’s configuration reference documents webServer and baseURL, including multiple web servers.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
CanaKit Raspberry Pi 4 4GB Starter PRO Kit - 4GB RAM
  • Includes Raspberry Pi 4 4GB Model B with 1.5GHz 64-bit quad-core CPU (4GB RAM)
  • Includes Pre-Loaded 32GB EVO+ Micro SD Card (Class 10), USB MicroSD Card Reader
  • CanaKit Premium High-Gloss Raspberry Pi 4 Case with Integrated Fan Mount, CanaKit Low Noise Bearing System Fan
  • CanaKit 3.5A USB-C Raspberry Pi 4 Power Supply (US Plug) with Noise Filter, Set of Heat Sinks, Display Cable - 6 foot (Supports up to 4K60p)
  • CanaKit USB-C PiSwitch (On/Off Power Switch for Raspberry Pi 4)

Run the tests in GitHub Actions

A Linux workflow needs locked project dependencies, Playwright browser binaries, and browser system dependencies. This representative workflow follows the steps in Playwright’s CI setup guide:

name: Visual tests
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-node@v6
        with:
          node-version: lts/*
      - run: npm ci
      - run: npx playwright install --with-deps
      - run: npx playwright test
      - uses: actions/upload-artifact@v5
        if: ${{ !cancelled() }}
        with:
          name: playwright-report
          path: playwright-report/
          retention-days: 30

The action versions shown are the versions used in the current Playwright CI example, not a promise that they will remain the right versions for every repository. Apply your repository’s pinning and update policies. For another CI provider, keep the same core sequence—install locked dependencies, install browsers and applicable OS dependencies, run tests, and retain useful reports—using that provider’s own job syntax.

Make screenshot comparisons stable

Match the baseline environment

Operating system, browser version and settings, hardware, power source, and headless mode can affect rendered output. Generate and review baselines in the same OS and browser environment used for CI. A container can help standardize the environment; Playwright documents container workflows for CI and visual regression work. If you test multiple browser projects or platforms, treat their images as distinct baselines rather than assuming one reference applies everywhere.

Control page state and dynamic content

Fix test data and make the page state deterministic where possible. Time-sensitive text, randomized content, live counters, or changing remote data can create diffs unrelated to a UI regression. Playwright supports a screenshot stylesheet through stylePath to filter genuinely volatile elements. Use it narrowly: masking a region also prevents the test from catching meaningful visual changes there.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use difference thresholds cautiously

The screenshot assertion accepts comparison options such as maxDiffPixels. A threshold can account for known rendering variance, but setting it too high can conceal changes the test should catch. Inspect the diff first, decide what variation is acceptable for the page, and record the chosen setting in the test rather than treating a passing result as proof that every pixel is identical.

Choose worker count and scaling deliberately

Playwright’s CI guide recommends one worker as a conservative choice for stability and reproducibility. A capable self-hosted runner may support more workers or sharding, but parallel jobs can complicate shared test data and reports. Shard when test volume justifies it and ensure reports from each shard can be collected. The guide also generally advises against caching browser binaries: restoring a cache may take as long as downloading, and Linux system dependencies are not cacheable.

Rank #4
Raspberry SC15184 Pi 4 Model B 2019 Quad Core 64 Bit WiFi Bluetooth (2GB)
  • Broadcom BCM2711, quad-core Cortex-A72 (ARM v8) 64-bit SoC @ 1. 5GHz
  • 2. 4 GHz and 5. 0 GHz IEEE 802. 11b/g/n/ac wireless LAN, Bluetooth 5. 0, BLE
  • 2 × USB 3. 0 ports, 2 x USB 2. 0 Ports
  • 2 × micro HDMI ports supproting up to 4Kp60 video resolution
  • Micro SD card slot for loading operating system and data storage

Represent the intended Indian user experience

The team’s location does not require an India-based runner for screenshot comparisons. The reviewed Playwright guidance documents portable Linux and container workflows, but does not establish India-specific provider prices, runner availability, performance, or data-residency requirements. If the React product serves users in India, choose test routes and states that reflect the intended language, content, currency, and viewport behavior. Validate runner region and compliance needs with the CI provider if those matter to your organization.

Review snapshot changes and diagnose failures

Update references only when the change is intended

When a UI change is deliberate, run npx playwright test --update-snapshots, inspect the changed images, and commit the new references with the code change. Do not automatically accept every CI-generated image: a baseline is a reviewed expectation, not simply the latest output.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use reports and traces safely

When a comparison fails, inspect the test output and HTML report, then use the trace viewer to examine the actions and page state leading to failure. Reports, traces, and logs may contain credentials, tokens, source code, or application data. Store artifacts only in trusted storage and limit access and retention according to your team’s security needs.

Best Value
CanaKit Raspberry Pi 5 16GB Starter Kit PRO - Turbine Black (128GB Edition) (16GB RAM)
  • Includes Raspberry Pi 5 16GB with 2.4Ghz 64-bit quad-core CPU (16GB RAM)
  • Includes 128GB Micro SD Card pre-loaded with 64-bit Raspberry Pi OS, USB MicroSD Card Reader
  • CanaKit Turbine Black Case for the Raspberry Pi 5
  • CanaKit Low Noise Bearing System Fan
  • Mega Heat Sink - Black Anodized

Common problems and fixes

Symptom Likely cause What to check
Browser executable or shared-library error in CI Browser binaries or Linux dependencies were not installed in the runner. Run npx playwright install --with-deps in the job and confirm the runner OS is supported by your chosen setup.
Test times out navigating to the local app The server command, readiness URL, port, or startup environment does not match the React app. Run the configured command locally; verify it binds to the expected interface and that the configured readiness URL responds.
Local screenshots pass but CI shows broad diffs Baseline and CI may differ in OS, browser version, settings, fonts, or headless environment. Align the baseline-generation environment with CI, or deliberately maintain separate references for different projects/platforms.
Small regions change on every run Content may be dynamic or test data is not fixed. Stabilize the data and state; if a region is truly irrelevant and volatile, consider a narrow screenshot stylesheet rather than masking meaningful UI.
Snapshot update creates many unexplained changes The app state or rendering environment changed, or the update was run without inspecting output. Review the visual diff and environment before accepting updates; avoid committing bulk changes that have not been explained.
Artifacts expose sensitive information Reports, traces, or logs can preserve app content and execution data. Restrict artifact storage and access, and retain only what the team needs for diagnosis.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you need a screenshot endpoint rather than an in-repository visual regression test, ScreenshotNeo is a website screenshot API and MCP server for developers. A single GET request can return a PNG, JPEG, WebP, or PDF. For example, save a capture of your deployed React route with cURL:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://your-react-site.example/ -o shot.webp

See the ScreenshotNeo API documentation for request parameters. The service removes cookie/consent banners, newsletter popups, and chat widgets before capture; those cleanup steps can be turned off. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers report the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo free: 1,000 screenshots a month, no card required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Cost, reliability, and when to use each approach

Playwright visual tests run in your CI environment, so their operational cost and runtime depend on your own runners, test scope, browser setup, and parallelism; the official material reviewed here does not establish India-specific pricing or performance. They are the right fit when you need a change-detection test tied to your source code and reviewed reference images. A screenshot API is useful when your task is to capture a URL without maintaining browser automation in the caller; an API capture alone is not a replacement for a committed Playwright baseline and assertion. For either approach, decide how failures are surfaced, how artifacts or returned images are handled, and what data the capture may contain.

Frequently Asked Questions

Does the CI runner have to be located in India?

No India-specific runner requirement is established for screenshot comparisons. Use the environment and data-handling controls your organization requires.

Should I use screenshot API captures as Playwright baselines?

This guide’s Playwright test compares browser-rendered screenshots to committed references. An API can capture a URL, but the supplied setup does not establish it as a substitute for Playwright’s assertion workflow.

Quick Recap

Bestseller No. 1
CanaKit Raspberry Pi 5 Starter Kit PRO - Turbine Black (128GB Edition) (8GB RAM)
CanaKit Raspberry Pi 5 Starter Kit PRO - Turbine Black (128GB Edition) (8GB RAM)
Includes Raspberry Pi 5 with 2.4Ghz 64-bit quad-core CPU (8GB RAM); CanaKit Turbine Black Case for the Raspberry Pi 5
$259.95
Bestseller No. 2
CanaKit Raspberry Pi 4 4GB Starter PRO Kit - 4GB RAM
CanaKit Raspberry Pi 4 4GB Starter PRO Kit - 4GB RAM
Includes Raspberry Pi 4 4GB Model B with 1.5GHz 64-bit quad-core CPU (4GB RAM); Includes Pre-Loaded 32GB EVO+ Micro SD Card (Class 10), USB MicroSD Card Reader
$159.99
Bestseller No. 4
Raspberry SC15184 Pi 4 Model B 2019 Quad Core 64 Bit WiFi Bluetooth (2GB)
Raspberry SC15184 Pi 4 Model B 2019 Quad Core 64 Bit WiFi Bluetooth (2GB)
Broadcom BCM2711, quad-core Cortex-A72 (ARM v8) 64-bit SoC @ 1. 5GHz; 2. 4 GHz and 5. 0 GHz IEEE 802. 11b/g/n/ac wireless LAN, Bluetooth 5. 0, BLE
$92.97
Bestseller No. 5
CanaKit Raspberry Pi 5 16GB Starter Kit PRO - Turbine Black (128GB Edition) (16GB RAM)
CanaKit Raspberry Pi 5 16GB Starter Kit PRO - Turbine Black (128GB Edition) (16GB RAM)
Includes Raspberry Pi 5 16GB with 2.4Ghz 64-bit quad-core CPU (16GB RAM); CanaKit Turbine Black Case for the Raspberry Pi 5
$419.99

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

CI/CDGitHub ActionsPlaywrightReactScreenshotNeovisual regression testing

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.