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

For most Astro projects, start with Playwright Test: Astro lists it as an end-to-end testing option, and its built-in toHaveScreenshot() assertion creates reference screenshots on the first run and compares later runs against them. Add a small set of representative routes, generate and review the baselines, then run the tests in CI using a consistent browser environment.

How do I set up visual regression testing for an Astro website?

The basic workflow is to add Playwright Test, start Astro through Playwright’s webServer configuration, and add screenshot assertions to tests for important pages and states. The first run creates reference images; later runs flag visual differences. Astro’s testing guide names Playwright among its end-to-end testing options.

1. Add Playwright Test to the project

From the Astro project directory, run the setup command for the package manager the project already uses:

  • npm init playwright@latest
  • pnpm create playwright
  • yarn create playwright

The setup flow can create a test folder and optionally a GitHub Actions workflow. Inspect the generated configuration before using it: confirm the test directory, browser projects, and any CI choices match the repository.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

2. Start Astro for the browser tests

Use Playwright’s webServer setting to start the site and wait for its local URL before opening pages. Choose the command that matches what you intend to test: a development server is convenient during iteration, while a preview server can exercise a production build. The following is an example for a project with a dev script; adapt the command and URL to the scripts in your own package.json.

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

export default defineConfig({
  testDir: './tests',
  use: {
    baseURL: 'http://127.0.0.1:4321',
    viewport: { width: 1280, height: 800 },
    deviceScaleFactor: 1,
  },
  webServer: {
    command: 'npm run dev -- --host 127.0.0.1',
    url: 'http://127.0.0.1:4321',
    reuseExistingServer: !process.env.CI,
  },
});

This example assumes the project’s Astro server listens on port 4321. If the project uses a different port, package manager, or production-preview script, change both the command and URL. Ensure the server command is available in CI and does not depend on an interactive prompt.

3. Write a screenshot test

Create tests/home.spec.ts (or use the location selected during setup):

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

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

Run it with npx playwright test. The screenshot assertion is part of Playwright Test; it is not a standalone browser screenshot command. Playwright waits until two consecutive page screenshots match, then compares the last capture with the expected image.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Start with a few representative cases rather than every URL: for example, the homepage, a typical content page, and a high-value responsive or interactive state. Set up predictable test data and route state so a changed screenshot reflects a UI change rather than different content.

How do screenshot baselines work?

The first run is baseline creation, not a meaningful pass/fail comparison. Playwright writes reference screenshots next to the test file in its snapshot directory. Review and commit those files with the test so future runs and code reviews have a known reference.

On subsequent runs, Playwright captures the page again and compares it with the committed reference. A difference produces a test failure and visual diff artifacts for inspection. A failing diff is a signal to investigate, not proof that the change is wrong: it may be an intended design update or an unstable page state.

Review and update intentional changes

  1. Open the failed test’s actual, expected, and diff images.
  2. Check whether the visual change is intended and whether the page was captured in the right state.
  3. If the design change is intentional, update the references with npx playwright test --update-snapshots.
  4. Review the updated images and include them in the same change as the UI change where possible.

Do not reflexively update snapshots just to make CI green; doing so can accept an accidental regression. The Playwright visual comparisons guide explains baseline creation, comparison, and snapshot updates.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

How do I keep Playwright visual tests stable?

Screenshot output can vary with the operating system, browser version, browser settings, hardware, power source, and headless mode. Playwright recommends generating and comparing screenshots in the same environment. Use the same browser project and dependency/browser setup locally and in CI; for stricter consistency, use the same container or operating-system image.

  • Fix the viewport and scale. Set a known viewport and device scale factor for each screenshot test. Add separate tests for responsive layouts instead of relying on whichever viewport happens to be active.
  • Wait for meaningful readiness. Navigate to the intended route and wait for its key content or fonts before capturing. Avoid arbitrary delays where a specific readiness condition is available.
  • Control volatile content. Stabilize timestamps, randomized content, animations, and external data in test mode. Mask a region only when it is genuinely variable and not the subject of the test.
  • Use thresholds carefully. Pixel tolerances can reduce noise, but can also hide small meaningful changes. Inspect actual diffs before relaxing comparison sensitivity.
  • Keep test state repeatable. Use fixed fixtures or seeded data, and make interactions explicit so a screenshot always represents the same state.

How do I run visual tests in CI?

Playwright’s CI guidance follows three main steps: install project dependencies, install the browser binaries and system dependencies, then run the tests. A typical npm sequence is:

npm ci
npx playwright install --with-deps
npx playwright test

Use the matching lockfile-based install command for the project’s package manager. Playwright recommends one worker in CI to prioritize stability and reproducibility; capable self-hosted systems can choose to parallelize or shard after confirming that the environment and tests remain reliable.

The Playwright continuous integration guide includes a GitHub Actions example that checks out the repository, sets up Node, runs npm ci, installs Playwright and its dependencies, runs the test suite, and uploads the HTML report. If a test fails, retain or inspect the report and screenshot diff artifacts before changing a baseline.

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.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Reliability and runtime trade-offs

Visual checks add browser startup and page-rendering work to the test suite. Keeping the initial route set focused makes failures easier to interpret and avoids scaling a noisy suite before its capture environment is stable. Running one CI worker can increase elapsed time compared with parallel execution, but reduces concurrency-related variability; measure the effect in your own pipeline before changing that setting.

For repeatability, pin project dependencies through the lockfile and install the corresponding Playwright browser in CI. A browser or operating-system upgrade can change rendering, so treat it as a baseline-affecting change: inspect the resulting diffs and update references deliberately rather than mixing unexplained snapshot changes into unrelated work.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Should I use hosted visual review instead?

Built-in Playwright snapshots are a practical starting point when the team wants reference images alongside tests and can review diffs in its existing code workflow. A hosted option is worth considering if visual-build review and collaboration outside that workflow solve a real team need. Both approaches still depend on stable rendering, and the hosted vendor’s current environment and review behavior should be checked in its documentation.

Approach Where baselines and review live Best fit
Playwright Test snapshots Reference images live with the tests in the repository; diffs can be reviewed with the code change. Teams seeking a direct, repository-based workflow.
Percy for Playwright Percy documents hosted visual builds and review, with a Playwright integration. Teams that need hosted build review or collaboration beyond local snapshot diffs.

Percy’s Playwright client library documentation describes the percy exec workflow, hosted builds, a drop-in integration for screenshot assertions, and an optional CI gate. It is an optional workflow choice, not a requirement for Astro visual tests.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Or skip the browser setup

For a one-off website capture or a screenshot workflow outside your Playwright suite, ScreenshotNeo provides a screenshot API and MCP server. A single GET request can return a PNG, JPEG, WebP, or PDF. For example, save this as shot.sh after setting your API key:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://astro.build -o shot.webp

See the ScreenshotNeo API documentation for the request options. Its consent handling removes known cookie/consent banners, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses indicate the page verdict and billing status. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf to AI agents and MCP clients.

ScreenshotNeo includes 1,000 screenshots a month on its free plan with no card required; paid plans start at $5 for 3,000 screenshots. It is a separate capture service, not a replacement for Playwright’s in-repository visual assertions and baseline review.

Sign up for ScreenshotNeo’s free plan and get 1,000 screenshots a month with no card.

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

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.