← Back to microsoft/playwright
microsoft / playwright · Issue No. 42807
1.64.0-next (main @ 07f1a6154); reproduces on 1.63 as well
import { test, expect } from '@playwright/test';
test('aria snapshot round-trip', async ({ page }) => {
await page.setContent(`<nav><a href="/">/</a></nav>`);
const snapshot = await page.locator('nav').ariaSnapshot();
console.log(JSON.stringify(snapshot));
await expect(page.locator('nav')).toMatchAriaSnapshot(snapshot);
});
Same thing happens with expect(locator).toMatchAriaSnapshot({ name: 'x.aria.yml' }) on the second run, or after --update-snapshots: the file Playwright writes on the first run fails to parse on the next run.
The snapshot is rendered with the name quoted (- link "/":) and matches on the next run.
"- navigation:\n - link /:\n - /url: /"
Error: expect(locator).toMatchAriaSnapshot(expected) failed
Error: Unterminated regex:
link /
^
Other names that start and end with / behave the same: /api/v1/ gives Unexpected input, /[a/ gives Unterminated regex. A name like /docs/ parses, but silently becomes the regex /docs/, so it also matches unrelated names such as xdocsx.
packages/isomorphic/ariaSnapshotRenderer.ts (createKey) skips JSON.stringify for any name that starts and ends with /, assuming it is a regex produced by convertToBestGuessRegex. That heuristic runs even when convertStringsToRegex is off (locator.ariaSnapshot(), snapshot files, "Expected/Received" in failure messages, codegen), so a literal name such as / is emitted unquoted and the key parser treats it as a regex.
Root-style links (<a href="/">/</a>) are common in breadcrumbs, path navigation and file/route tables.
I intend to work on this and will send a PR.
- Operating System: macOS (Darwin 25.6.0)
- Node.js: 24.8.0
- Browser: Chromium (bundled r1246)
- Playwright: main @ 07f1a6154
Relay reads this issue against the repository's contribution signals: the files it is likely to touch, how the maintainers triage work this size, and what the first contribution would exercise.
The full analysis for this issue is still being assembled. Until then, the description above and the thread on GitHub are the most reliable context.