#Screenshot comparison with toHaveScreenshot
AddedEvery assertion so far checked a fact: this text, this count, this URL. None of them notices that the price is now white on white, that the Add to cart button slid under the footer, or that a CSS refactor made every card 40 pixels taller. A user sees those at once; a toHaveText test passes straight through them. Visual comparison fills that gap: take a screenshot, compare it pixel by pixel with an approved one, and fail if they differ.
await expect(page).toHaveScreenshot() (or expect(locator) for one element) does three things. It waits until the page is stable: it takes screenshots until two in a row match, so a half-loaded page isn't captured. It compares that screenshot with the baseline (the "expected" image saved next to the test). And if there's no baseline yet, it writes one and fails, so a new visual test can never pass silently on its first run.
The mental model: a "spot the difference" puzzle with an answer sheet. The baseline is the approved picture, committed to git and reviewed like code. Every run draws the picture again and circles every difference. The hard part isn't drawing; it's deciding which differences matter, which is what thresholds and masks are for.
| Bug | toHaveText / toBeVisible | toHaveScreenshot |
|---|---|---|
| Wrong price text | catches it | catches it (as changed pixels) |
| Price rendered in the wrong colour or weight | misses it | catches it |
| Button pushed off screen or under another element | sometimes (click fails) | catches it |
| Layout broken at one viewport size | misses it | catches it (one screenshot per size) |
| A different user's name in the header | catches it if asserted | fails, which is noise: mask it |
Here is the first run of a brand-new visual test, then the second run:
import { test, expect } from "@playwright/test";
test("the sign-in page looks right", async ({ page }) => {
await page.goto("/practice/");
await expect(page).toHaveScreenshot();
});
test("the product list looks right", async ({ page }) => {
await page.goto("/practice/");
await page.getByLabel("Username").fill("rohit");
await page.getByLabel("Password").fill("playwright");
await page.getByRole("button", { name: "Sign in" }).click();
await expect(page.getByRole("listitem")).toHaveCount(8);
await expect(page.getByRole("list", { name: "Products" })).toHaveScreenshot("products.png");
});Running 2 tests using 1 worker
✘ 1 [chromium] › tests/visual.spec.ts:3:1 › the sign-in page looks right (365ms)
✘ 2 [chromium] › tests/visual.spec.ts:8:1 › the product list looks right (1.8s)
1) [chromium] › tests/visual.spec.ts:3:1 › the sign-in page looks right ──────────────────────────
Error: A snapshot doesn't exist at <project>/tests/visual.spec.ts-snapshots/the-sign-in-page-looks-right-1-chromium-darwin.png, writing actual.
3 | test("the sign-in page looks right", async ({ page }) => {
4 | await page.goto("/practice/");
> 5 | await expect(page).toHaveScreenshot();
| ^
6 | });
7 |
8 | test("the product list looks right", async ({ page }) => {
at <project>/tests/visual.spec.ts:5:3
attachment #1: the-sign-in-page-looks-right-1 (image/png) ──────────────────────────────────────
Expected: tests/visual.spec.ts-snapshots/the-sign-in-page-looks-right-1-chromium-darwin.png
Received: test-results/visual-the-sign-in-page-looks-right-chromium/the-sign-in-page-looks-right-1-actual.png
────────────────────────────────────────────────────────────────────────────────────────────────
Error Context: test-results/visual-the-sign-in-page-looks-right-chromium/error-context.md
2) [chromium] › tests/visual.spec.ts:8:1 › the product list looks right ──────────────────────────
Error: A snapshot doesn't exist at <project>/tests/visual.spec.ts-snapshots/products-chromium-darwin.png, writing actual.
13 | await expect(page.getByRole("listitem")).toHaveCount(8);
14 |
> 15 | await expect(page.getByRole("list", { name: "Products" })).toHaveScreenshot("products.png");
| ^
16 | });
17 |
at <project>/tests/visual.spec.ts:15:3
attachment #1: products (image/png) ────────────────────────────────────────────────────────────
Expected: tests/visual.spec.ts-snapshots/products-chromium-darwin.png
Received: test-results/visual-the-product-list-looks-right-chromium/products-actual.png
────────────────────────────────────────────────────────────────────────────────────────────────
Error Context: test-results/visual-the-product-list-looks-right-chromium/error-context.md
2 failed
[chromium] › tests/visual.spec.ts:3:1 › the sign-in page looks right ───────────────────────────
[chromium] › tests/visual.spec.ts:8:1 › the product list looks right ───────────────────────────Running 2 tests using 1 worker
✓ 1 [chromium] › tests/visual.spec.ts:3:1 › the sign-in page looks right (155ms)
✓ 2 [chromium] › tests/visual.spec.ts:8:1 › the product list looks right (1.6s)
2 passed (2.2s)- First run: no baseline exists. Each
toHaveScreenshottakes its screenshot, finds no file to compare with, writes the screenshot as the new baseline ("writing actual") and fails. That failure is deliberate (theupdateSnapshots: "default"mode): a CI run must never go green just because the baseline was missing. - The error says exactly where the baseline went:
tests/visual.spec.ts-snapshots/, next to the test file. The first test has no name argument, so Playwright made one from the title (the-sign-in-page-looks-right-1); the second is namedproducts.png. Both got-chromium-darwinadded: the project name and the operating system the run happened on (macOS isdarwin). - Second run: the baselines exist, the new screenshots match them pixel for pixel, and both tests pass. From now on, any visible change to the sign-in page or the product list fails these tests until someone approves it.
- The product test waits for all 8 products before the screenshot (
toHaveCount(8)).toHaveScreenshotwaits for the page to stop changing, but the shop shows "Loading products…" for about 0.7 s, which is perfectly stable, so without that line the baseline could be a picture of the spinner. expect(locator).toHaveScreenshot()captures just that element: the product grid, not the header. Smaller screenshots fail for fewer unrelated reasons, which is the single best way to keep visual tests useful.
To see a real failure, the next suite takes a baseline, then runs the same page with one CSS rule changed, the kind of change a refactor makes by accident. Two tests in one file that use the same name (products.png) share one baseline, so the second test compares the changed page with the first test's picture. The first run creates the baseline for the @baseline test only; the second run is the normal run.
import { test, expect, type Page } from "@playwright/test";
async function openShop(page: Page) {
await page.goto("/practice/");
await page.getByLabel("Username").fill("rohit");
await page.getByLabel("Password").fill("playwright");
await page.getByRole("button", { name: "Sign in" }).click();
await expect(page.getByRole("listitem")).toHaveCount(8);
}
const products = (page: Page) => page.getByRole("list", { name: "Products" });
const unbold = ".product .price { font-weight: 400; }"; // the "accidental" change
test("the product list @baseline", async ({ page }) => {
await openShop(page);
await expect(products(page)).toHaveScreenshot("products.png");
});
test("after a CSS change: prices lose their bold", async ({ page }) => {
await openShop(page);
await page.addStyleTag({ content: unbold });
await expect(products(page)).toHaveScreenshot("products.png");
});
test("the same change, allowing 100 different pixels", async ({ page }) => {
await openShop(page);
await page.addStyleTag({ content: unbold });
await expect(products(page)).toHaveScreenshot("products.png", { maxDiffPixels: 100 });
});
test("the same change, allowing 5% different pixels", async ({ page }) => {
await openShop(page);
await page.addStyleTag({ content: unbold });
await expect(products(page)).toHaveScreenshot("products.png", { maxDiffPixelRatio: 0.05 });
});Running 1 test using 1 worker
A snapshot doesn't exist at <project>/tests/products.spec.ts-snapshots/products-chromium-darwin.png, writing actual.
✓ 1 [chromium] › tests/products.spec.ts:13:1 › the product list @baseline (1.8s)
1 passed (2.5s)Running 4 tests using 1 worker
✓ 1 [chromium] › tests/products.spec.ts:13:1 › the product list @baseline (1.6s)
✘ 2 [chromium] › tests/products.spec.ts:18:1 › after a CSS change: prices lose their bold (1.9s)
✘ 3 [chromium] › tests/products.spec.ts:24:1 › the same change, allowing 100 different pixels (2.2s)
✓ 4 [chromium] › tests/products.spec.ts:30:1 › the same change, allowing 5% different pixels (1.6s)
1) [chromium] › tests/products.spec.ts:18:1 › after a CSS change: prices lose their bold ─────────
Error: expect(locator).toHaveScreenshot(expected) failed
Locator: getByRole('list', { name: 'Products' })
1992 pixels (ratio 0.01 of all image pixels) are different.
Snapshot: products.png
Call log:
- Expect "toHaveScreenshot(products.png)" getByRole('list', { name: 'Products' }) with timeout 5000ms
- verifying given screenshot expectation
- waiting for getByRole('list', { name: 'Products' })
- locator resolved to <ul class="products" data-products="" aria-label="Products">…</ul>
- taking element screenshot
- disabled all CSS animations
- waiting for fonts to load...
- fonts loaded
- attempting scroll into view action
- waiting for element to be stable
- 1992 pixels (ratio 0.01 of all image pixels) are different.
- waiting 100ms before taking screenshot
- waiting for getByRole('list', { name: 'Products' })
- locator resolved to <ul class="products" data-products="" aria-label="Products">…</ul>
- taking element screenshot
- disabled all CSS animations
- waiting for fonts to load...
- fonts loaded
- attempting scroll into view action
- waiting for element to be stable
- captured a stable screenshot
- 1992 pixels (ratio 0.01 of all image pixels) are different.
19 | await openShop(page);
20 | await page.addStyleTag({ content: unbold });
> 21 | await expect(products(page)).toHaveScreenshot("products.png");
| ^
22 | });
23 |
24 | test("the same change, allowing 100 different pixels", async ({ page }) => {
at <project>/tests/products.spec.ts:21:32
attachment #1: products (image/png) ────────────────────────────────────────────────────────────
Expected: tests/products.spec.ts-snapshots/products-chromium-darwin.png
Received: test-results/products-after-a-CSS-change-prices-lose-their-bold-chromium/products-actual.png
Diff: test-results/products-after-a-CSS-change-prices-lose-their-bold-chromium/products-diff.png
────────────────────────────────────────────────────────────────────────────────────────────────
Error Context: test-results/products-after-a-CSS-change-prices-lose-their-bold-chromium/error-context.md
2) [chromium] › tests/products.spec.ts:24:1 › the same change, allowing 100 different pixels ─────
Error: expect(locator).toHaveScreenshot(expected) failed
Locator: getByRole('list', { name: 'Products' })
1992 pixels (ratio 0.01 of all image pixels) are different.
Snapshot: products.png
Call log:
- Expect "toHaveScreenshot(products.png)" getByRole('list', { name: 'Products' }) with timeout 5000ms
- verifying given screenshot expectation
- waiting for getByRole('list', { name: 'Products' })
- locator resolved to <ul class="products" data-products="" aria-label="Products">…</ul>
- taking element screenshot
- disabled all CSS animations
- waiting for fonts to load...
- fonts loaded
- attempting scroll into view action
- waiting for element to be stable
- 1992 pixels (ratio 0.01 of all image pixels) are different.
- waiting 100ms before taking screenshot
- waiting for getByRole('list', { name: 'Products' })
- locator resolved to <ul class="products" data-products="" aria-label="Products">…</ul>
- taking element screenshot
- disabled all CSS animations
- waiting for fonts to load...
- fonts loaded
- attempting scroll into view action
- waiting for element to be stable
- captured a stable screenshot
- 1992 pixels (ratio 0.01 of all image pixels) are different.
25 | await openShop(page);
26 | await page.addStyleTag({ content: unbold });
> 27 | await expect(products(page)).toHaveScreenshot("products.png", { maxDiffPixels: 100 });
| ^
28 | });
29 |
30 | test("the same change, allowing 5% different pixels", async ({ page }) => {
at <project>/tests/products.spec.ts:27:32
attachment #1: products (image/png) ────────────────────────────────────────────────────────────
Expected: tests/products.spec.ts-snapshots/products-chromium-darwin.png
Received: test-results/products-the-same-change-allowing-100-different-pixels-chromium/products-actual.png
Diff: test-results/products-the-same-change-allowing-100-different-pixels-chromium/products-diff.png
────────────────────────────────────────────────────────────────────────────────────────────────
Error Context: test-results/products-the-same-change-allowing-100-different-pixels-chromium/error-context.md
2 failed
[chromium] › tests/products.spec.ts:18:1 › after a CSS change: prices lose their bold ──────────
[chromium] › tests/products.spec.ts:24:1 › the same change, allowing 100 different pixels ──────
2 passed (9.5s)// Prints every file under the given folders, sorted, so the page can show what a run really wrote.
import { readdirSync } from "node:fs";
import { join } from "node:path";
const walk = (d) => readdirSync(d, { withFileTypes: true }).flatMap((e) => (e.isDirectory() ? walk(join(d, e.name)) : [join(d, e.name)]));
for (const dir of process.argv.slice(2)) for (const f of walk(dir).sort()) console.log(f);tests/products.spec.ts
tests/products.spec.ts-snapshots/products-chromium-darwin.png
test-results/.last-run.json
test-results/products-after-a-CSS-change-prices-lose-their-bold-chromium/error-context.md
test-results/products-after-a-CSS-change-prices-lose-their-bold-chromium/products-actual.png
test-results/products-after-a-CSS-change-prices-lose-their-bold-chromium/products-diff.png
test-results/products-after-a-CSS-change-prices-lose-their-bold-chromium/products-expected.png
test-results/products-the-same-change-allowing-100-different-pixels-chromium/error-context.md
test-results/products-the-same-change-allowing-100-different-pixels-chromium/products-actual.png
test-results/products-the-same-change-allowing-100-different-pixels-chromium/products-diff.png
test-results/products-the-same-change-allowing-100-different-pixels-chromium/products-expected.png--update-snapshots --grep @baselineruns only the first test and writes its baseline (the run still prints "A snapshot doesn't exist … writing actual", but passes, because writing it was requested).--update-snapshotsis how you approve a change: run it after an intentional redesign, look at the new images in the diff of your pull request, and commit them.- The second test adds one CSS rule,
font-weight: 400on the prices, and fails: 1992 pixels differ, which rounds to a ratio of 0.01 (1%) of the image. Notice the call log: it took a screenshot, compared, waited 100 ms, took another, got "a stable screenshot", and only then gave up. Playwright never fails on a frame caught mid-change. - The failure writes three images into the test's folder in
test-results/:products-expected.png(a copy of the baseline),products-actual.png(what the page looks like now) andproducts-diff.png(the changed pixels highlighted). The HTML report shows them side by side with a slider; on CI you download them as an artifact. maxDiffPixels: 100still fails: 1992 is more than 100. A small pixel budget like this absorbs anti-aliasing noise (a few dozen pixels along text edges) and still catches a real change.maxDiffPixelRatio: 0.05(5%) passes: 1% of the image changed, under the limit. That's the danger of ratio thresholds on big screenshots: every price on the page changed weight and the test didn't notice. Keep tolerances small, and prefer small element screenshots to big page screenshots with a big tolerance.- The file list shows the one baseline (
tests/products.spec.ts-snapshots/products-chromium-darwin.png), the three images for each failed test, anerror-context.mdper failure (Chapter 11), and.last-run.json, which--last-failedreads.
From the 1.65 API docs, for toHaveScreenshot (set them per call, or for every test under expect: { toHaveScreenshot: { … } } in the config):
| Option | What it does | Default |
|---|---|---|
maxDiffPixels | how many pixels may differ | unset (none) |
maxDiffPixelRatio | what fraction of pixels may differ, 0 to 1 | unset (none) |
threshold | how different one pixel's colour must be to count as changed (YIQ colour space), 0 strict to 1 lax | 0.2 |
mask | locators to paint over with a solid box before comparing | none |
maskColor | the box colour | #FF00FF (pink) |
animations | "disabled" stops CSS animations and transitions; finite ones jump to their end | "disabled" |
caret | "hide" hides the blinking text cursor | "hide" |
fullPage | the whole scrollable page instead of the viewport | false |
stylePath | a CSS file applied only while capturing (hide volatile parts) | none |
scale | "css" (one pixel per CSS pixel) or "device" | "css" |
threshold and maxDiffPixels answer different questions: threshold decides whether one pixel changed (a slightly different shade of green doesn't count), maxDiffPixels decides how many changed pixels are allowed. Leave threshold at its default unless you have a reason.
Some parts of a screen differ on every run, or for every user, and aren't what the test is about: the signed-in name, a date, an ad, a live counter. mask paints a solid box over them before comparing. Here the header's baseline is taken as Rohit, and the same header is then checked as Ana, first with a plain mask and then with a mask over a box of fixed size:
import { test, expect, type Page } from "@playwright/test";
async function signInAs(page: Page, username: string) {
await page.goto("/practice/");
await page.getByLabel("Username").fill(username);
await page.getByLabel("Password").fill("playwright");
await page.getByRole("button", { name: "Sign in" }).click();
await expect(page.getByRole("listitem")).toHaveCount(8);
}
const masked = (page: Page) => ({ mask: [page.getByText(/^Signed in as/)] });
// Test-only CSS, applied after the functional checks: the name's box gets the same width for every user.
const fixNameWidth = (page: Page) => page.addStyleTag({ content: ".who { display: inline-block; min-width: 12em; }" });
test("header as rohit, masked @baseline", async ({ page }) => {
await signInAs(page, "rohit");
await expect(page.getByRole("banner")).toHaveScreenshot("header.png", masked(page));
});
test("header as ana, masked", async ({ page }) => {
await signInAs(page, "ana");
await expect(page.getByRole("banner")).toHaveScreenshot("header.png", masked(page));
});
test("header as rohit, fixed-width name, masked @baseline", async ({ page }) => {
await signInAs(page, "rohit");
await fixNameWidth(page);
await expect(page.getByRole("banner")).toHaveScreenshot("header-fixed.png", masked(page));
});
test("header as ana, fixed-width name, masked", async ({ page }) => {
await signInAs(page, "ana");
await fixNameWidth(page);
await expect(page.getByRole("banner")).toHaveScreenshot("header-fixed.png", masked(page));
});Running 2 tests using 1 worker
A snapshot doesn't exist at <project>/tests/header.spec.ts-snapshots/header-chromium-darwin.png, writing actual.
✓ 1 [chromium] › tests/header.spec.ts:14:1 › header as rohit, masked @baseline (1.8s)
A snapshot doesn't exist at <project>/tests/header.spec.ts-snapshots/header-fixed-chromium-darwin.png, writing actual.
✓ 2 [chromium] › tests/header.spec.ts:24:1 › header as rohit, fixed-width name, masked @baseline (1.7s)
2 passed (4.1s)Running 4 tests using 1 worker
✓ 1 [chromium] › tests/header.spec.ts:14:1 › header as rohit, masked @baseline (1.6s)
✘ 2 [chromium] › tests/header.spec.ts:19:1 › header as ana, masked (1.9s)
✓ 3 [chromium] › tests/header.spec.ts:24:1 › header as rohit, fixed-width name, masked @baseline (1.6s)
✓ 4 [chromium] › tests/header.spec.ts:30:1 › header as ana, fixed-width name, masked (1.5s)
1) [chromium] › tests/header.spec.ts:19:1 › header as ana, masked ────────────────────────────────
Error: expect(locator).toHaveScreenshot(expected) failed
Locator: getByRole('banner')
126 pixels (ratio 0.01 of all image pixels) are different.
Snapshot: header.png
Call log:
- Expect "toHaveScreenshot(header.png)" getByRole('banner') with timeout 5000ms
- verifying given screenshot expectation
- waiting for getByRole('banner')
- locator resolved to <header class="bar">…</header>
- taking element screenshot
- disabled all CSS animations
- waiting for fonts to load...
- fonts loaded
- attempting scroll into view action
- waiting for element to be stable
- 126 pixels (ratio 0.01 of all image pixels) are different.
- waiting 100ms before taking screenshot
- waiting for getByRole('banner')
- locator resolved to <header class="bar">…</header>
- taking element screenshot
- disabled all CSS animations
- waiting for fonts to load...
- fonts loaded
- attempting scroll into view action
- waiting for element to be stable
- captured a stable screenshot
- 126 pixels (ratio 0.01 of all image pixels) are different.
19 | test("header as ana, masked", async ({ page }) => {
20 | await signInAs(page, "ana");
> 21 | await expect(page.getByRole("banner")).toHaveScreenshot("header.png", masked(page));
| ^
22 | });
23 |
24 | test("header as rohit, fixed-width name, masked @baseline", async ({ page }) => {
at <project>/tests/header.spec.ts:21:42
attachment #1: header (image/png) ──────────────────────────────────────────────────────────────
Expected: tests/header.spec.ts-snapshots/header-chromium-darwin.png
Received: test-results/header-header-as-ana-masked-chromium/header-actual.png
Diff: test-results/header-header-as-ana-masked-chromium/header-diff.png
────────────────────────────────────────────────────────────────────────────────────────────────
Error Context: test-results/header-header-as-ana-masked-chromium/error-context.md
1 failed
[chromium] › tests/header.spec.ts:19:1 › header as ana, masked ─────────────────────────────────
3 passed (7.9s)- The two
@baselinetests record Rohit's header twice: once as it is, once with the name's box given a fixed width. In both, a pink box covers "Signed in as rohit". - Ana with the plain mask fails: 126 pixels differ. The mask covered her name, but "Signed in as ana" is shorter than "Signed in as rohit", so the box is narrower and starts further right; the strip where Rohit's box was and Ana's isn't is what differs. A mask hides the content, not its size.
- Ana with the fixed-width name passes:
min-width: 12emmakes the name's box the same size for both users, so the pink box lands in exactly the same place and everything else (brand, Account link, cart count, Log out) is identical. - The CSS is added only after the functional part of the test, and only for the capture. The cleaner home for it is a stylesheet passed as
stylePath(applied only while the screenshot is taken);addStyleTagis used here so the whole example fits on the page. - Mask by locator, not by coordinates, so the box follows the element if the layout moves, and mask as little as possible: a mask over half the page is a test of the other half. Block-level elements (a whole paragraph, like the delivery estimate in the next topic) don't have this problem, because their box is full width whatever the text.
Browsers render text and shapes differently, and so do operating systems (fonts, anti-aliasing, font hinting). So Playwright never compares a Firefox screenshot with a Chromium baseline: the file name carries the project and the platform. Here's one test in three browsers, after a --update-snapshots run:
import { defineConfig, devices } from "@playwright/test";
export default defineConfig({
testDir: "./tests",
use: { baseURL: "https://rohit-playwright.pages.dev" },
projects: [
{ name: "chromium", use: { ...devices["Desktop Chrome"] } },
{ name: "firefox", use: { ...devices["Desktop Firefox"] } },
{ name: "webkit", use: { ...devices["Desktop Safari"] } },
],
});import { test, expect } from "@playwright/test";
test("sign-in page", async ({ page }) => {
await page.goto("/practice/");
await expect(page.getByRole("heading", { name: "Sign in" })).toBeVisible();
await expect(page).toHaveScreenshot("signin.png");
});Running 3 tests using 3 workers
A snapshot doesn't exist at <project>/tests/signin.spec.ts-snapshots/signin-chromium-darwin.png, writing actual.
✓ 2 [chromium] › tests/signin.spec.ts:3:1 › sign-in page (491ms)
A snapshot doesn't exist at <project>/tests/signin.spec.ts-snapshots/signin-webkit-darwin.png, writing actual.
✓ 1 [webkit] › tests/signin.spec.ts:3:1 › sign-in page (1.1s)
A snapshot doesn't exist at <project>/tests/signin.spec.ts-snapshots/signin-firefox-darwin.png, writing actual.
✓ 3 [firefox] › tests/signin.spec.ts:3:1 › sign-in page (1.8s)
3 passed (4.2s)// Prints every file under the given folders, sorted, so the page can show what a run really wrote.
import { readdirSync } from "node:fs";
import { join } from "node:path";
const walk = (d) => readdirSync(d, { withFileTypes: true }).flatMap((e) => (e.isDirectory() ? walk(join(d, e.name)) : [join(d, e.name)]));
for (const dir of process.argv.slice(2)) for (const f of walk(dir).sort()) console.log(f);tests/signin.spec.ts
tests/signin.spec.ts-snapshots/signin-chromium-darwin.png
tests/signin.spec.ts-snapshots/signin-firefox-darwin.png
tests/signin.spec.ts-snapshots/signin-webkit-darwin.png- Three projects, one test, so three runs and three baselines:
signin-chromium-darwin.png,signin-firefox-darwin.pngandsignin-webkit-darwin.png. The default name pattern is roughly{name}-{projectName}-{platform}{ext}inside<test file>-snapshots/. darwinisprocess.platformon a Mac. On a Linux CI runner the same test looks forsignin-chromium-linux.png, which doesn't exist, so the first CI run fails with "A snapshot doesn't exist". Baselines made on your Mac are no use to a Linux CI machine.- The usual fix is to make and update baselines in the same environment CI uses: run the update inside the official Docker image (Chapter 12) on your Mac, or have a CI job run
--update-snapshotsand commit or upload the result. The docs put it plainly: run the tests in the same environment the baselines were made in. - The name pattern is configurable with
snapshotPathTemplatein the config (tokens such as{testFilePath},{arg},{projectName},{platform},{ext}). Teams that only ever compare on Linux sometimes drop{platform}so there's one baseline per browser.