Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
Set Playwright Test’s snapshotPathTemplate to a directory under your test tree. A template such as {testDir}/__screenshots__/{testFilePath}/{arg}{ext} puts every visual-regression baseline below one shared tests/__screenshots__ root while retaining the test-file path and snapshot name. Add {/projectName} when separate projects need independent references.
Configure one shared snapshot directory
Playwright Test resolves a relative snapshotPathTemplate from the directory containing your Playwright configuration file. The following TypeScript configuration creates a single baseline root and keeps each test’s folder structure underneath it:
import { defineConfig } from '@playwright/test';
export default defineConfig({
testDir: './tests',
snapshotPathTemplate: '{testDir}/__screenshots__/{testFilePath}/{arg}{ext}',
});
If your configuration is in the project root and testDir is ./tests, a screenshot named landing.png in tests/checkout/cart.spec.ts is stored below tests/__screenshots__/checkout/cart.spec.ts/landing.png (the exact separators depend on the operating system). The important parts are the common __screenshots__ root, {testFilePath} for ownership and collision avoidance, and {arg} for the name supplied to the assertion.
Recommended Free Tools
Keep projects in separate trees
Chromium, Firefox and WebKit can render the same page differently. If your configured projects represent materially different rendering environments, include the project token:
#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
import { defineConfig } from '@playwright/test';
export default defineConfig({
testDir: './tests',
snapshotPathTemplate:
'{testDir}/__screenshots__{/projectName}/{testFilePath}/{arg}{ext}',
});
The optional slash before projectName is deliberate. Playwright includes the slash and project name only when the token has a value, so an unnamed project does not acquire an empty path segment. Named projects receive their own subtree, preventing one project’s baseline from overwriting another’s.
Use screenshot assertions to create and compare references
The path template controls Playwright Test snapshots, not arbitrary files produced by page.screenshot({ path }). Use toHaveScreenshot (or the locator form) for visual regression references:
import { test, expect } from '@playwright/test';
test('home page matches its reference', async ({ page }) => {
await page.goto('https://example.com');
await expect(page).toHaveScreenshot('landing.png');
});
On the first run, Playwright captures and writes the reference. Later runs capture the page again and compare it with that file. If you omit a name, Playwright derives one from the test and assertion; supplying a stable name such as landing.png or landing.webp makes the file easier to locate. PNG is the default format, and WebP references are lossless according to the visual-comparisons guidance.
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 problemsCapture a component instead of the whole page
test('header matches its reference', async ({ page }) => {
await page.goto('https://example.com');
await expect(page.locator('header')).toHaveScreenshot('header.png');
});
The same template is used for locator snapshots. The {arg} token receives the supplied snapshot name, so different names remain distinct even when they are asserted in one test file.
Know the available path tokens
The TestConfig API supports these substitutions in snapshotPathTemplate:
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
| Token | What it contributes | When to use it |
|---|---|---|
{arg} |
The assertion’s supplied snapshot name | Use explicit names such as landing.png. |
{ext} |
The extension derived from the snapshot | Preserves PNG or WebP without hard-coding an extension. |
{testDir} |
The configured test directory | Places references alongside tests. |
{testFilePath} |
Test-file path relative to the test directory | Prevents collisions and shows ownership. |
{testFileDir} |
The test file’s containing directory | Useful when you need directory-level grouping. |
{testFileBaseName} |
Base name of the test file | Creates shorter, file-oriented paths. |
{testFileName} |
Test file name | Retains the filename, including its extension. |
{testName} |
The test name | Use only when generated names are acceptable. |
{projectName} |
Configured project name | Separates browser, viewport or environment baselines. |
{platform} |
Platform identifier | Separates operating-system-specific references when required. |
{snapshotDir} |
Playwright’s snapshot directory value | Useful when composing a template around an existing snapshot location. |
Tokens are case-sensitive. Keep {testFilePath} when multiple test files reuse names such as header.png; removing it can make unrelated assertions compete for the same filename.
Generate, review and commit baselines
- Place
snapshotPathTemplatein the exported configuration. - Add named
toHaveScreenshotassertions to the tests that define your visual contract. - Run the relevant test. Missing references are generated under the configured common root.
- Inspect the new images and the test output for unintended differences.
- Add the complete
__screenshots__tree to version control. Review reference changes like code changes.
When a deliberate UI change is approved, regenerate references with:
Free tools Windows power users keep installed
One-click scans. No signup required.
npx playwright test --update-snapshots
Use this flag intentionally: it updates the expected files rather than proving that the current rendering still matches the old contract. Review the resulting diff before committing.
Find a snapshot path from inside a test
Code that needs the resolved filename should ask Playwright rather than reconstructing the template:
const reference = test.info().snapshotPath('header.png', { kind: 'screenshot' });
console.log(reference);
The returned path reflects the configured template, project name and platform tokens. This is safer than concatenating strings, particularly on Windows or in a multi-project configuration.
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.
Choose a layout that remains maintainable
Common root with test paths
{testDir}/__screenshots__/{testFilePath}/{arg}{ext} is the simplest choice when all projects intentionally share one rendering environment. It gives reviewers one baseline tree while retaining the source test’s path.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Common root with project separation
{testDir}/__screenshots__{/projectName}/{testFilePath}/{arg}{ext} is safer when projects differ in browser engine, viewport, color scheme, device scale factor or other rendering settings. It avoids silently treating one project’s pixels as another project’s expectation.
Explicit names and stable ownership
Prefer descriptive names (checkout-empty.png, checkout-filled.png) and keep the source test path in the template. A short, generated path may look tidy but makes it harder to identify which test owns a failing image.
Rendering consistency is part of the test
Playwright warns that browser rendering can vary with the host operating system, browser version, settings, hardware, power source (battery versus adapter), headless mode and other factors. Create and compare references in the same kind of environment whenever possible. In practice, that means pinning browser versions, using a consistent CI image, keeping viewport and device scale settings stable, and avoiding a workflow in which developers generate references on one operating system while CI compares them on another.
A path template cannot solve environmental drift. If a diff appears without a code change, first check the browser revision, operating system image, fonts, headed versus headless mode, and project configuration before accepting new snapshots.
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
Troubleshooting common failures
Files are not under the expected folder
Check that the option is in the configuration actually loaded by the test command and that {testDir} points to the directory you expect. Relative template paths resolve from the configuration directory, not from the shell’s current directory.
Two tests overwrite one reference
Add {testFilePath} and give each assertion a distinct {arg}. Reusing a name such as page.png is safe only when the test-file path remains in the template.
Projects show unexpected diffs
If projects use different browsers or rendering settings, add {/projectName}. Then generate references for each named project and commit the resulting subdirectories. Sharing one image across genuinely different renderers creates noisy or misleading failures.
The first run fails because no baseline exists
That is normal for a new assertion. Run the test once to generate the reference, inspect it, and commit it. Do not use --update-snapshots as an automatic fix for an unexplained failure.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →References change on every machine
Align browser versions, operating systems, fonts, viewport, scale factor and headless mode. Keep baseline generation and comparison in the same controlled environment. Investigate external content and animations as well; a moving or late-loading page can produce legitimate pixel differences even when the template is correct.
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.
Or skip the browser setup
For one-off captures, documentation images or a separate screenshot pipeline, ScreenshotNeo returns a screenshot or PDF from one request. It accepts consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups and chat widgets before capture; each cleanup step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers report the page verdict and billing result.
Use the API documentation at https://screenshotneo.com/docs/ for authentication and options. A minimal cURL call is:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
The same request in Python:
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
And in Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
ScreenshotNeo also provides an MCP server with take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients. Plans include 1,000 screenshots per month free with no card; paid plans start at $5 for 3,000. Create a free ScreenshotNeo account.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
FAQ
Does snapshotPathTemplate move screenshots made with page.screenshot?
No. It controls references used by Playwright Test screenshot assertions. A direct page.screenshot({ path }) call writes exactly where its own path specifies.
Which format should a reference use?
PNG is the default. You can supply a WebP filename; the visual-comparisons guidance describes WebP as lossless.
Was snapshotPathTemplate always available?
The option was added in Playwright 1.28. Projects using an older Playwright version should upgrade before relying on it.
Frequently Asked Questions
Does snapshotPathTemplate move screenshots made with page.screenshot?
No. It controls references used by Playwright Test screenshot assertions. A direct page.screenshot({ path }) call writes exactly where its own path specifies.
Which format should a reference use?
PNG is the default. You can supply a WebP filename; the visual-comparisons guidance describes WebP as lossless.
Was snapshotPathTemplate always available?
The option was added in Playwright 1.28. Projects using an older Playwright version should upgrade before relying on it.
Quick 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.

