Skip to content

fix(aria-snapshot): quote names that only look like regexes - #42811

Merged
Yury Semikhatsky (yury-s) merged 1 commit into
microsoft:mainfrom
Abnoz01:fix-42807
Sep 23, 2026
Merged

Yury Semikhatsky (yury-s) merged 1 commit into
microsoft:mainfrom
Abnoz01:fix-42807

Conversation

@Abnoz01

Copy link
Copy Markdown
Contributor

Summary

  • renderAriaSnapshotAsYaml left any name starting and ending with / unquoted, even when convertStringsToRegex was off, so <a href="/">/</a> rendered as - link /: and the parser failed with Unterminated regex on the next run.
  • Only leave a name unquoted when regex conversion actually produced it; add a round-trip test.

Fixes #42807

The renderer left any name that starts and ends with "/" unquoted,
assuming it was a generated regex. That also applied when regex
conversion was off, so a literal name such as "/" produced a snapshot
the parser rejects with "Unterminated regex".

Fixes microsoft#42807
if (name) {
const stringifiedName = name.startsWith('/') && name.endsWith('/') ? name : JSON.stringify(name);
key += ' ' + stringifiedName;
// Only a name that was actually converted to a regex may be left unquoted.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drop the comment

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "MCP"

8692 passed, 1474 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

4 flaky ⚠️ [chromium-library] › library/chromium/chromium.spec.ts:436 › should produce network events, routing, and annotations for Service Worker (advanced) `@chromium-ubuntu-22.04-node20`
⚠️ [firefox-library] › library/browsercontext-cookies-third-party.spec.ts:257 › third party 'Partitioned;' cookies `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-library] › library/browsercontext-cookies-third-party.spec.ts:470 › top level 'Partitioned;' cookie and same origin iframe `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-library] › library/trace-viewer-scrub.spec.ts:226 › should reveal snapshot when hovering an action or picking a locator during playback `@firefox-ubuntu-22.04-node20`

52029 passed, 1250 skipped


Merge workflow run.

@yury-s
Yury Semikhatsky (yury-s) merged commit 4afcfb1 into microsoft:main Sep 23, 2026
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: toMatchAriaSnapshot cannot parse the snapshot that ariaSnapshot() produces for names starting and ending with "/"

2 participants