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

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Use visual regression tests with dark mode explicitly enabled: save an approved screenshot as the baseline, then compare later captures against it. With Playwright, set the browser context’s color scheme to dark and use toHaveScreenshot(). Keep the capture environment consistent, review image diffs before updating baselines, and treat a site’s manual theme toggle as a separate site-specific step.

Set up a dark-mode screenshot test with Playwright

The examples below use Playwright Test. Set dark mode in the test configuration so each test starts with the same color-scheme preference. Playwright documents light and dark as supported values for colorScheme.

Configure the project

In playwright.config.ts, add use.colorScheme to the project or shared use settings:

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.
import { defineConfig } from '@playwright/test';

export default defineConfig({
  use: {
    colorScheme: 'dark',
  },
});

If only selected tests need dark mode, configure it for that project or test instead of applying it globally.

#1 Best Overall
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents

Capture a baseline and compare future runs

Create a test such as tests/dark-mode.spec.ts:

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

test('home page dark-mode appearance', async ({ page }) => {
  await page.goto('https://example.com');
  await expect(page).toHaveScreenshot('home-dark.png', {
    fullPage: true,
  });
});

Replace https://example.com with the page you own or are authorized to test. On the first run, Playwright creates the reference screenshot. On later runs, toHaveScreenshot() compares the rendered page with that reference and reports visual differences.

Run the test with your project’s usual Playwright command, for example npx playwright test tests/dark-mode.spec.ts. Inspect the generated diff and actual image when a comparison fails. If the change is intentional, update the reference using Playwright’s snapshot update mechanism, such as npx playwright test tests/dark-mode.spec.ts --update-snapshots, then review and commit the new baseline. Do not update snapshots automatically just to make a failing test pass.

Control theme, viewport, and interaction state

Choose the right dark-mode state

colorScheme: 'dark' emulates the browser’s dark color-scheme preference. It catches changes for sites that respond to that preference, typically through CSS media queries or application logic. If the site has a manual theme switch, emulation alone may not activate it. Navigate to the page, then use a stable, site-appropriate interaction to select dark mode before the screenshot. The exact control and persistence behavior depend on that site’s implementation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors

For a one-off change within a test, Playwright also supports await page.emulateMedia({ colorScheme: 'dark' });. Apply it before capturing the page. If both system preference and a manual switch are relevant, test them as distinct states when they can produce different results.

Cover the states that matter

Decide which routes and conditions represent real risk rather than taking one screenshot and assuming it covers the whole site. A useful test matrix can include:

  • Key pages, such as the home page, account screens, and high-use workflows.
  • Supported viewport sizes, especially layouts where dark-mode contrast or component spacing changes.
  • Important interaction states, such as an open menu, dialog, validation message, or selected navigation item.
  • Different browsers or projects when your support requirements call for them.

Keep each screenshot’s name and test context clear enough that a diff identifies the page and state that changed. Add coverage as needed; do not assume that a single full-page image covers every interactive state.

Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.

Make screenshot comparisons reliable

Keep the rendering environment stable

Playwright warns that browser rendering can vary with the host operating system, browser version, settings, hardware, power source, headless mode, and other factors. Run baseline creation and subsequent comparisons in the same environment where practical. In CI, use a consistent operating system and browser setup, and avoid casually changing browser versions between baseline updates.

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

Differences caused by fonts, animations, timestamps, rotating content, or asynchronous data can obscure meaningful changes. Stabilize data and page state where possible. For unavoidable volatile regions, use a screenshot stylesheet to hide or neutralize them; Playwright’s screenshot assertion supports stylePath for injecting stylesheets. Scope those rules narrowly so the test does not hide a real dark-mode defect.

Set thresholds with care

Playwright’s screenshot assertion offers a perceived color-difference threshold and a maximum differing-pixel option. A threshold can tolerate minor rendering noise, but a permissive value may also conceal a meaningful contrast, color, or layout regression. Start with the default behavior, inspect the actual diffs, and adjust only when you can explain which harmless differences the setting is meant to tolerate.

Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

Review before replacing a baseline

A baseline is an approved reference, not simply the newest output. When a comparison changes, determine whether the difference is an intended design update, environmental noise, or a regression. Update the stored screenshot only after that review; otherwise the new baseline can silently normalize a defect.

Choose between local and hosted visual review

Native Playwright screenshot assertions keep capture, comparison, and reference snapshots in the test project. A hosted service may be more suitable when a team needs shared cloud review or a particular integration workflow. Product documentation describes capabilities, not independent test results; verify current plan limits, pricing, and fit before committing.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Approach What the documentation describes Considerations
Playwright Test Reference screenshots in the project; subsequent runs compare captures with those references. Fits teams that want visual assertions in their existing Playwright tests. The comparison environment still needs to be kept consistent.
Chromatic with Playwright Chromatic documents uploading a page archive for cloud snapshot generation and pixel-diff review. Its snapshot documentation describes capture variations such as browser, theme, and viewport. Its documented Playwright path involves Playwright test utilities and a Storybook archive step. Confirm the setup and dimensions available for your intended workflow.
Percy with Playwright Percy’s Playwright client documents page snapshots and options including full-page capture and ignored regions. Assess integration requirements, review workflow, and how ignored regions fit your noise-control needs.

Before selecting a hosted workflow, also compare where baselines are owned, who can review changes, CI integration, retention, usage limits, browser and theme coverage, and current pricing. Pricing and plan limits for these services are not established here.

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common dark-mode comparison failures

The screenshot still looks light

  • Confirm the test context or page is using colorScheme: 'dark' before navigation or capture.
  • Check whether the site responds to the system color-scheme preference. A manual theme switch may need to be activated separately.
  • If the switch stores a preference, make sure the test starts from a known state and selects the intended mode consistently.

The test fails on every run with small differences

  • Compare the baseline and test environment’s operating system, browser version, settings, and headless mode.
  • Identify changing content such as timestamps or animations; stabilize it or target it with a narrowly scoped screenshot stylesheet.
  • Inspect the diff before raising thresholds. Use threshold options only for understood, acceptable noise.

A snapshot update hides a regression

  • Do not accept a new baseline solely because the assertion failed.
  • Review the diff and verify whether the appearance change was intended.
  • Update snapshots deliberately and keep the reviewed baseline with the test project.

A hosted capture differs from local Playwright

Compare the configured browser, theme, viewport, page state, and ignored or hidden regions. Hosted and local workflows can differ in capture configuration; verify the service’s current documented settings rather than assuming the images are interchangeable.

Or skip the browser setup

ScreenshotNeo can capture a URL with one GET request. See the ScreenshotNeo API documentation for available parameters.

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

ScreenshotNeo accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. For dark-mode regression tests, keep in mind that a screenshot API capture is not a replacement for Playwright’s repeatable browser test and baseline comparison: use the capture approach that matches your review workflow.

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.

Sign up free for 1,000 screenshots a month with no card.

Frequently Asked Questions

Can Playwright test both light and dark mode?

Yes. Use separate project or test configurations with colorScheme: 'light' and colorScheme: 'dark', then maintain separate screenshot expectations for each state.

Does dark color-scheme emulation click a website’s theme toggle?

No. It sets the browser’s color-scheme preference. A site’s manual switch must be handled according to that site’s implementation.

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.

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