The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Use Playwright’s colorScheme: 'dark' emulation to put the page into dark mode, then use Playwright Test’s expect(page).toHaveScreenshot() to compare the rendered page with a reviewed reference image. Test dark and light states separately, keep the capture environment consistent, and treat any tolerance or baseline update as a deliberate review decision.
Set up a dark-mode screenshot test
Screenshot assertions are part of the Playwright Test runner. On its first run, toHaveScreenshot() creates a reference image; later runs compare the rendered output with that baseline. This example shows the documented API pattern, but has not been run against a particular application.
import { test, expect } from '@playwright/test';
test('renders the home page in dark mode', async ({ page }) => {
await page.emulateMedia({ colorScheme: 'dark' });
await page.goto('/');
await expect(page).toHaveScreenshot('home-dark.png');
});
Configure a working baseURL if the test uses a relative path such as /. Otherwise, pass the page’s full address to page.goto(). Set the emulated scheme before navigation when possible so the application can select its initial theme using prefers-color-scheme.
Choose where to set the color scheme
Playwright documents three ways to emulate a scheme. Choose the scope that matches your test organization:
#1 Best Overall
- 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
| Scope | Example | Best suited to |
|---|---|---|
| One page during a test | await page.emulateMedia({ colorScheme: 'dark' }); |
A test that changes scheme or covers a specific page state. |
| Tests in a file or describe block | test.use({ colorScheme: 'dark' }); |
A group of tests that should all run with the same scheme. |
| A browser context | await browser.newContext({ colorScheme: 'dark' }); |
Tests that create their own context rather than using the standard fixture. |
| A Playwright Test project | use: { colorScheme: 'dark' } |
A separately configured project in a test matrix. |
The documented scheme values are light and dark. Choose the level appropriate to your suite and avoid setting contradictory values at multiple levels. See Playwright’s emulation guide for the configuration context.
Test light and dark as independent visual states
If your product supports both schemes, give each one an explicit test and snapshot name. Independent tests make it clear which state changed and avoid one test’s scheme switch leaking into another.
import { test, expect } from '@playwright/test';
test('home page in light mode', async ({ page }) => {
await page.emulateMedia({ colorScheme: 'light' });
await page.goto('/');
await expect(page).toHaveScreenshot('home-light.png');
});
test('home page in dark mode', async ({ page }) => {
await page.emulateMedia({ colorScheme: 'dark' });
await page.goto('/');
await expect(page).toHaveScreenshot('home-dark.png');
});
You can also express the two states as separate Playwright Test projects, setting use: { colorScheme: 'light' } in one and use: { colorScheme: 'dark' } in the other. This is useful when the same suite should run under both settings. Keep snapshot names unambiguous so a diff identifies the intended scheme.
Rank #2
- 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
Make screenshots repeatable before tuning diffs
A visual assertion is useful only if an unexpected diff points to a meaningful change. Playwright notes that screenshot output can vary with host operating system, browser version, settings, hardware, power source, headless mode, and other factors. Its visual comparison documentation cautions that “Browser rendering can vary based on the host OS, version, settings, hardware, power source (battery vs. power adapter), headless mode, and other factors.”
- Generate and compare baselines with consistent operating system, browser version, and capture settings.
- If you intentionally test more than one browser or platform, keep the expected images appropriate to those environments instead of treating every rendering difference as an application regression.
- Wait for application content to be ready before asserting. The screenshot assertion itself waits until two consecutive page screenshots match before it compares the last capture with the expectation; that helps with transient rendering, but does not eliminate cross-environment differences.
- Keep the tested viewport, device scale, and other relevant browser settings stable between baseline generation and comparison.
For details on snapshot behavior and maintenance, see Playwright’s visual comparisons guide.
Handle dynamic content without hiding dark-mode defects
Animations, clocks, rotating ads, or other changing elements can make snapshots noisy. Playwright’s stylePath option can apply a stylesheet while taking a screenshot, including to suppress volatile elements. Use it only for content outside the behavior under test. Hiding a component whose colors, visibility, or contrast matter in dark mode can conceal the very regression the test should catch.
Rank #3
- 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.
For example, a test-only stylesheet may hide a timestamp that changes on every render, while leaving the header, navigation, cards, and theme-dependent components visible. Review the affected elements whenever the stylesheet changes. See the snapshot assertion documentation for screenshot options.
Set comparison tolerance deliberately
Playwright’s screenshot comparison options include a perceived-color-difference threshold and limits on the number or proportion of differing pixels. The API reference documents a default YIQ color-difference threshold of 0.2; this is a configuration default, not a universal recommendation for dark-mode testing. Difference limits can be set in test or project configuration.
Recommended Free Tools
- Start with a strict comparison if the rendering environment is stable and the design is expected to be deterministic.
- If harmless rendering noise remains, adjust the threshold or difference budget only after inspecting the diff and understanding its source.
- Do not raise allowances simply to silence a failing test: a larger tolerance may also permit genuine color, contrast, or layout regressions.
Consult the snapshot assertion API reference for the options supported by your installed Playwright version.
Rank #4
- 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 and update approved baselines
When a design change is intentional, regenerate the expected images with:
npx playwright test --update-snapshots
Inspect the resulting images and diffs, then commit only approved snapshots with the code change. Playwright recommends versioning and reviewing snapshots; do not refresh them reflexively just to turn a failed build green.
Troubleshoot common failures
| Symptom | Likely cause | What to check |
|---|---|---|
| The page still looks light | The app may not respond to prefers-color-scheme, may use a stored/manual theme setting, or may have received the emulation too late. |
Set the scheme before navigation, confirm the application’s theme behavior, and check whether a saved preference overrides the system preference. |
| The first run creates a snapshot instead of reporting a mismatch | No reference image exists yet for that test and environment. | Review the generated image as the proposed baseline, then retain it only if it represents the intended appearance. |
| A snapshot differs on another machine or CI runner | Operating system, browser, rendering settings, hardware, power source, or headless mode may differ. | Align capture environments or manage expectations separately for deliberate platform/browser coverage before changing tolerance. |
| Repeated failures show moving content | A clock, animation, rotating ad, or other dynamic element changes between captures. | Stabilize the content if possible; otherwise use stylePath narrowly for elements outside the tested behavior. |
| A test passes despite a visible small change | The threshold or differing-pixel allowance may be too permissive. | Inspect the diff and tighten the comparison settings to reflect the visual contract. |
| Snapshot update changes many files | The environment or a shared style change may have altered broad rendering, or the update command may be applied too widely. | Review each diff, confirm the intended project and environment, and avoid committing unexplained baseline changes. |
Or skip the browser setup
If you need a rendered page capture outside a Playwright test, ScreenshotNeo provides a one-call screenshot API. It is not a replacement for a Playwright visual assertion or its versioned baselines; use it when you want a screenshot response without managing browser capture yourself. See the ScreenshotNeo API documentation.
Free tools Windows power users keep installed
One-click scans. No signup required.
Best Value
- 【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.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo accepts cookie/consent banners and removes 60+ known consent platforms, 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 identify 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 shots per month with no card; paid plans start at $5 for 3,000 shots. More at ScreenshotNeo.
Sign up for 1,000 free screenshots a month, with no card required.
Frequently Asked Questions
How to test dark mode with Playwright?
Set the page’s emulated color scheme to dark and assert its expected appearance with Playwright Test’s toHaveScreenshot().
How do I compare screenshots in Playwright?
Use Playwright Test’s expect(page).toHaveScreenshot(); the first run establishes an expected image and later runs compare against it.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsQuick Recap
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.




