What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Configure Playwright’s ARIA snapshot paths and matching behavior in your JavaScript or TypeScript project configuration; the YAML is the generated accessibility-tree baseline, not the configuration file itself. Use expect.toMatchAriaSnapshot.pathTemplate to keep ARIA baselines in their own directory, and include project and platform tokens if tests run across browsers or operating systems. Then create or refresh files with npx playwright test --update-snapshots.
What Playwright’s snapshot YAML is—and what it is not
An ARIA snapshot is a YAML representation of a locator’s accessibility tree. Playwright compares that representation with the expected snapshot when an assertion such as toMatchAriaSnapshot runs. The YAML file is therefore the expected test data; settings for where it goes and how it is matched belong in the project’s JavaScript or TypeScript Playwright configuration, commonly playwright.config.ts.
This distinction matters when configuring a project: you do not write the path template inside a YAML file. You set it in Playwright configuration, write an assertion in a test, and let Playwright create or update the YAML baseline. Playwright also documents page.ariaSnapshot() and locator.ariaSnapshot() for obtaining a YAML representation during test execution; those methods are useful when you need to inspect the tree rather than assert against a stored baseline.
Set a separate path for ARIA snapshot files
Use the ARIA-specific expect.toMatchAriaSnapshot.pathTemplate option when you want ARIA files separated from other snapshot types. The global snapshotPathTemplate covers snapshot assertions more broadly, including screenshot and value snapshots. The following is a practical starting configuration:
import { defineConfig } from '@playwright/test';
export default defineConfig({
testDir: './tests',
snapshotPathTemplate: '{testDir}/__snapshots__/{testFilePath}/{arg}{ext}',
expect: {
toMatchAriaSnapshot: {
pathTemplate: '{testDir}/__aria__/{testFilePath}/{arg}{ext}',
children: 'contain',
},
},
});
In this example, the global template establishes a convention for general snapshots, while ARIA assertions use the dedicated __aria__ tree. Keeping these policies distinct makes the generated files easier to find and reduces the chance of mixing baselines with different purposes. You can omit the global setting if you only need to change ARIA snapshot paths.
The available template tokens include {testDir}, {snapshotDir}, {testFilePath}, {testFileDir}, {testFileName}, {testFileBaseName}, {testName}, {arg}, {ext}, {projectName}, and {platform}. Use the tokens that express the directory and collision-avoidance rules your project needs. In particular, {testFilePath} retains the test file’s relative path, while {arg} and {ext} account for the name and extension associated with the snapshot assertion. Optional tokens can result in their immediately preceding separator being included only when that token has a value.
Name the snapshot in the test
Give the assertion a name when you want a clear, stable filename such as main.aria.yml:
import { expect, test } from '@playwright/test';
test('main content has the expected accessible structure', async ({ page }) => {
await page.goto('/');
await expect(page.getByRole('main')).toMatchAriaSnapshot('main.aria.yml');
});
The explicit filename is the assertion’s snapshot argument; the configured template determines where Playwright places it. Avoid relying on memory to locate a generated file when the template is customized. Within a test, testInfo.snapshotPath('main.aria.yml', { kind: 'aria' }) resolves the corresponding path programmatically. That can be useful in diagnostics or test utilities that need to refer to the configured location rather than hard-code a directory.
Choose how much of the accessibility tree must match
Set the default child matching policy with expect.toMatchAriaSnapshot.children. The choice determines how strict an assertion is about children beneath the snapshot node:
contain: the expected children may appear within a larger tree. This is useful when the test cares about required accessible content but unrelated additions may be acceptable.equal: use the documented equal-children behavior when the children represented by the snapshot should match as a set rather than merely appear within a larger group.deep-equal: require recursive equality, which is the strict choice when nested descendants are part of the contract being tested.
These modes are not interchangeable. A broad containment check can tolerate added children; recursive equality can detect structural changes deeper in the tree. Prefer the least permissive mode that reflects what the test is meant to protect, rather than making every test maximally strict by default. A stricter assertion can also create more maintenance when legitimate interface changes alter descendants.
An individual ARIA snapshot can override the configured default using a top-level /children property in that snapshot. This gives a suite a consistent default while allowing a particular assertion to document a deliberate exception. Keep the override close to the snapshot whose matching requirement differs, so a reader can understand the intended strictness without tracing unrelated configuration.
Separate files by project, browser, or platform
If the same test runs in multiple Playwright projects, use {projectName} and, where relevant, {platform} in the ARIA path template. For example:
Recommended Free Tools
expect: {
toMatchAriaSnapshot: {
pathTemplate:
'{testDir}/__aria__/{projectName}/{platform}/{testFilePath}/{arg}{ext}',
children: 'contain',
},
},
This produces a visible separation between each project and platform’s baselines. It is especially useful when projects represent different browsers or operating systems: rendered pages and fonts can differ, and a shared baseline path can otherwise lead to one run overwriting the expectation used by another. Use tokens that correspond to actual dimensions of variation in your test matrix; do not add separate copies for dimensions that are not distinct projects in your configuration.
When adopting a new layout, decide whether snapshots should be shared intentionally or isolated by project. Shared files reduce duplication but assume equivalent accessibility trees; separated files are clearer when the expected tree legitimately varies. A path template determines organization, not whether the underlying interface should differ, so investigate unexpected browser-specific snapshots rather than treating every difference as automatically correct.
Create or update the YAML baselines
Run the Playwright test command with snapshot updates enabled to create missing baselines or update expected values according to the selected update mode:
npx playwright test --update-snapshots
# shorthand
npx playwright test -u
The default updateSnapshots mode is 'missing': missing snapshots are created, but existing mismatches are not automatically replaced. Choose a mode deliberately in configuration:
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Rank #4
| Mode | Effect | When to choose it |
|---|---|---|
'missing' |
Creates missing snapshots; this is the default. | When new tests need baselines without silently accepting changes to existing expectations. |
'changed' |
Updates mismatches and creates missing files. | When you intend to refresh changed expected values and review those changes. |
'all' |
Updates all snapshots executed by the run. | When you deliberately want to regenerate the executed baselines. |
'none' |
Disables snapshot updates. | When the run must not write snapshots. |
Updating a baseline changes what the test considers expected. Review the resulting YAML diff as a test change, especially when using 'changed' or 'all'; do not treat a green update run by itself as proof that the new accessibility structure is correct. The ARIA snapshot guide notes that matching snapshots are not updated by the command unless the selected mode requires it.
Use inline snapshots when the expected YAML belongs in code
File-based YAML keeps baselines separate from test logic. If a snapshot is embedded in source code instead, updateSourceMethod controls how Playwright writes inline snapshot updates. The documented choices are:
patch(the default) creates a unified diff.3waywrites merge-conflict markers.overwritereplaces the source snapshot value.
Use the strategy that best fits how your team reviews source changes. These are write strategies for inline snapshots; they do not choose the directory for file-based ARIA YAML. Keep that distinction clear when diagnosing why an update modified a test file rather than creating a separate baseline.
Keep legacy path configuration only when needed
snapshotDir is the older base-directory setting and is marked discouraged in the current API reference, which recommends snapshotPathTemplate for configuring snapshot locations. For a new layout, use the template option, or the ARIA-specific pathTemplate when only ARIA files need separate handling. Retain snapshotDir when preserving an existing directory convention is important for compatibility, then plan any migration around the paths your tests currently resolve.
Best Value
The documented API identifies snapshotPathTemplate as added in Playwright v1.28 and updateSourceMethod as added in v1.50. Match configuration options to the Playwright version installed in the project: version-sensitive settings may not be available in older installations. If a setting is rejected or appears to have no effect, check the installed version and current configuration shape before changing the snapshot files.
Troubleshoot missing, misplaced, or noisy snapshots
- No YAML file appears: confirm the assertion ran and that updates are enabled for the situation. With the default
'missing'mode, a missing file can be created, but an existing mismatch is not necessarily rewritten. Check the configured ARIApathTemplateand the project’stestDirto find the resolved location. - The file is in an unexpected directory: inspect the effective
expect.toMatchAriaSnapshot.pathTemplatefirst. If no ARIA-specific template is set, inspect the broader snapshot path policy and the values supplied by tokens such as{testFilePath},{arg}, and{ext}. - One browser run replaces another run’s baseline: make the paths project-specific with
{projectName}; add{platform}when platform separation is required. Verify the test projects have distinct names and that the template is applied to the ARIA assertion. - A changed tree fails instead of updating: that is consistent with
updateSnapshots: 'missing', which does not automatically replace existing mismatches. Select an appropriate update mode for the intended refresh, then inspect the diff. - The assertion passes despite extra content: check whether the configured child mode is
contain. Chooseequalordeep-equalwhere the test needs a stricter child comparison, or add an individual/childrenoverride. - The update changes source code rather than a YAML file: determine whether the test uses an inline snapshot. In that case,
updateSourceMethodgoverns the source update strategy; file path templates apply to file-based snapshots. - A configuration option is not recognized: verify the installed Playwright version, especially when using
snapshotPathTemplateorupdateSourceMethod. The API documents their introduction in v1.28 and v1.50 respectively.
Or skip the browser setup
ScreenshotNeo is a website screenshot API, not an ARIA snapshot runner: it captures a rendered page as an image or PDF and does not create Playwright accessibility-tree YAML. If you need a visual capture without setting up a browser flow, one GET request returns the screenshot. See the ScreenshotNeo API documentation for request options.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo removes cookie and consent banners, newsletter popups, and chat widgets before the shot; each cleanup step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and the response includes X-Page-Verdict and X-Billed headers. Its MCP server provides screenshot tools for AI agents, including Claude, Cursor, and other MCP clients. The Free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots. Those visual captures are a separate task from testing an accessibility tree with Playwright.
Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteQuick 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.

