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

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

If an existing Playwright snapshot does not change after you run an update command, first verify that you are using the Playwright Test runner and that the test containing the assertion is actually selected. In the normal case, run npx playwright test --update-snapshots. The bare flag means changed: mismatching snapshots are rewritten, while matching snapshots remain untouched. Without the flag, Playwright defaults to missing, so an existing mismatch is reported rather than replaced.

Use the right command and project

The documented update switch belongs to the Playwright Test CLI. Run it from the project that owns the tests and configuration:

npx playwright test --update-snapshots

If the repository has more than one Playwright configuration, select the intended one explicitly:

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.
npx playwright test -c playwright.config.ts --update-snapshots

You can also use the short form:

npx playwright test -u

These commands only affect tests that execute during that invocation. Running a different package script, a single unrelated test, or a project with another configuration can make a successful update appear to do nothing.

Confirm that the test is selected

List the tests before updating:

npx playwright test --list

Use your normal file, project, grep, or test-title filters with --list to check that the snapshot assertion is included. Then run the same selection with --update-snapshots. If the test is not listed, no snapshot writer will run.

Understand Playwright’s four update modes

Update behavior is controlled by the CLI flag and by the updateSnapshots configuration value. The documented configuration default is missing.

Mode What it does When to use it
missing Creates snapshots that do not exist; leaves existing mismatches for review. Normal test runs and cautious baseline creation.
changed Updates snapshots whose actual value differs from the baseline; leaves matching files alone. Refreshing intentional changes.
all Regenerates every snapshot produced by the selected tests, including matching ones. Deliberate full-baseline regeneration after an environment or design change.
none Disables snapshot updates. Enforcing read-only baselines, especially in CI.

The bare --update-snapshots flag selects changed. If you need a complete regeneration, specify the scope deliberately and inspect the resulting diff:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
npx playwright test --update-snapshots=all

Use all sparingly. It can rewrite thousands of valid baselines and conceal an accidental environment change.

Set the mode in configuration

A configuration value can override the behavior used by your project. Check for a setting such as:

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

export default defineConfig({
  updateSnapshots: 'missing', // all | changed | missing | none
});

If it is set to none, an update command may be blocked by the project’s policy. Change it only for the update run you intend to perform, then restore the appropriate CI-safe value.

Identify which snapshot you are updating

Playwright has separate assertion families, and they do not all store output in the same way.

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.

Screenshot snapshots

Visual assertions such as expect(page).toHaveScreenshot() write image files, normally in a per-test snapshot directory. The actual location can change when your configuration defines snapshotPathTemplate. Named screenshot formats also affect the extension. Read the failure output for the expected path and compare that exact file instead of searching only the repository root.

A screenshot mismatch can represent a real UI change, a browser difference, fonts, operating-system rendering, animation, or unstable data. Decide whether the rendering difference is expected before updating. Increasing pixel-difference tolerances merely to silence an unexplained failure can hide a regression.

Text and binary snapshots

Text, buffer, and other value snapshots use their own assertion APIs and expected-file conventions. Verify the assertion in the test, the snapshot name, and the extension shown in the failure report. Updating a screenshot command will not rewrite a text snapshot, and vice versa.

ARIA snapshots

ARIA snapshots represent the accessibility tree. Generation and comparison can wait for the configured expect timeout. If the page is still loading or the tree is not stable before that timeout, the assertion fails before a new baseline is written. Increase the relevant expect timeout only after checking why the tree is slow:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import { test, expect } from '@playwright/test';

test('navigation accessibility tree', async ({ page }) => {
  await page.goto('https://example.test');
  await expect(page.getByRole('navigation')).toMatchAriaSnapshot({
    timeout: 15_000,
  });
});

Use a stable locator and wait for the application state that should be represented. A timeout is not evidence that the old snapshot is correct; it means Playwright did not finish producing a comparable tree.

Check source-embedded snapshot updates

Some workflows keep snapshots inside source files rather than separate expected files. The CLI option --update-source-method controls how those values are proposed:

Method Result Review workflow
patch Creates a unified diff. Inspect and apply the patch deliberately.
3way Adds conflict markers when source and generated values diverge. Resolve the markers manually, then run the test again.
overwrite Writes the generated value directly into the source. Review the source diff immediately.

The default is patch. Therefore, an update can succeed without silently overwriting the source file. Look for the generated patch or conflict markers:

npx playwright test --update-snapshots --update-source-method=patch

Choose overwrite only when direct replacement is part of your reviewed workflow.

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

Use a repeatable update procedure

  1. Record the environment. Note the Playwright package version, browser revision, operating system, Node.js version, and the configuration file being used.
  2. Install the intended browsers. A missing or different browser installation can prevent the test from running or produce different pixels.
  3. List the tests. Run npx playwright test --list with the same filters you plan to use for updating.
  4. Run one focused test. Update a single file or title first, so the diff is understandable.
  5. Update changed snapshots. Use npx playwright test --update-snapshots.
  6. Inspect the diff and failure artifacts. Keep changes that reflect an intentional product change; investigate unexplained changes.
  7. Run without update mode. A clean verification run must pass with ordinary snapshot comparison, not because updates are still enabled.
  8. Commit the expected files. Include image, text, ARIA, or source changes that belong to the test; do not commit temporary reports or unrelated regenerated baselines.

Why updates work locally but not in CI

CI can select a different project, use another configuration, or run another Playwright and browser version. Compare the local and CI environments rather than assuming the baseline is wrong. Install the browsers and required dependencies in CI, and keep the worker count stable; Playwright’s CI guidance recommends one worker for reproducibility and stability.

Also check whether CI is configured with updateSnapshots: 'none' or whether the command omits --update-snapshots. A production-style CI run should normally reject unexpected changes, not rewrite the repository. Generate or review new baselines in a controlled environment, then run CI in comparison mode.

Common errors and precise fixes

“The command ran, but the old file is unchanged”

  • Verify that the assertion’s test was selected with --list.
  • Check whether the mismatch is in a different snapshot directory selected by snapshotPathTemplate.
  • Check the update mode. missing does not replace an existing snapshot; use changed or an explicit CLI update.
  • For embedded snapshots, inspect the patch produced by the default patch method.

“No snapshot was created”

  • Run the test without filters and confirm the assertion is reached.
  • Read the first failure: navigation, authentication, selector, or timeout failures stop snapshot generation.
  • Confirm the test is using Playwright Test rather than another runner that does not implement this CLI flag.

“The update command itself is unknown”

Run the command through the project’s installed runner: npx playwright test. Check the installed package version and the script that your package manager invokes. A global or different executable may not support the same options.

“ARIA snapshot update times out”

  • Wait for the application’s loaded state or a stable locator before the assertion.
  • Increase the assertion timeout for genuinely slow pages.
  • Investigate repeated asynchronous rendering instead of raising the timeout indefinitely.

“The screenshot differs on every run”

  • Disable or wait for animations and transitions in the test setup.
  • Stabilize time, random data, network responses, fonts, and responsive viewport settings.
  • Use the same browser and operating-system class for baseline generation and verification.
  • Only after the cause is understood, consider documented pixel-difference limits.

“A full update created a huge diff”

That is the expected risk of all. Revert the broad change, rerun the focused test with changed, and regenerate only the snapshots tied to the intentional UI or accessibility change.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your goal is simply to capture a website image rather than maintain a Playwright test baseline, ScreenshotNeo provides a single-request screenshot API. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers.

Use the API documentation at https://screenshotneo.com/docs/ for all options. A minimal cURL request 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 offers an MCP server with take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. It supports full-page and element captures, device and viewport settings, retina scale, dark mode, custom CSS and JavaScript, clicks, waits, request blocking, headers, cookies, user agents, authorization, timezone and geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed links, asynchronous webhooks, bulk capture of up to 100 URLs per call, PDFs, HTML/CSS rendering, and a usage API. Every feature is on every plan. The Free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.

How to keep snapshot updates safe

  • Generate baselines with a pinned Playwright version and known browser installation.
  • Keep update mode off in ordinary verification and CI runs.
  • Review image, text, and ARIA diffs as code changes, not as automatic formatting.
  • Use focused test selection before broad regeneration.
  • Document intentional environment changes when a baseline must be regenerated.

Frequently Asked Questions

Does -u mean update every snapshot?

No. In the Playwright Test CLI, bare -u selects the changed mode. Use an explicit all value for intentional full regeneration.

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

Can I update snapshots from a single test file?

Yes. Apply the file, project, title, or grep filter you normally use, verify it with --list, then add --update-snapshots.

Should CI run with snapshot updates enabled?

Usually no. CI should compare against committed baselines; generate reviewed updates in a controlled environment and keep CI configured to reject unexpected differences.

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.