Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
feat: page version of toMatchAriaSnapshot (#39950)
Dmitry Gozmanf6e14f9d73b4
diff --git a/docs/src/api/class-pageassertions.md b/docs/src/api/class-pageassertions.mdindex 7b0a983cb6..ce5de2f09b 100644--- a/docs/src/api/class-pageassertions.md+++ b/docs/src/api/class-pageassertions.md@@ -127,6 +127,104 @@ Whether to perform case-insensitive match. [`option: ignoreCase`] option takes p### option: PageAssertions.NotToHaveURL.timeout = %%-csharp-java-python-assertions-timeout-%%* since: v1.18+## async method: PageAssertions.toMatchAriaSnapshot+* since: v1.60+* langs:+ - alias-java: matchesAriaSnapshot++Asserts that the page body matches the given [accessibility snapshot](../aria-snapshots.md).++**Usage**++```js+await page.goto('https://demo.playwright.dev/todomvc/');+await expect(page).toMatchAriaSnapshot(`+ - heading "todos"+ - textbox "What needs to be done?"+`);+```++```python async+await page.goto("https://demo.playwright.dev/todomvc/")+await expect(page).to_match_aria_snapshot('''+ - heading "todos"+ - textbox "What needs to be done?"+''')+```++```python sync+page.goto("https://demo.playwright.dev/todomvc/")+expect(page).to_match_aria_snapshot('''+ - heading "todos"+ - textbox "What needs to be done?"+''')+```++```csharp+await page.GotoAsync("https://demo.playwright.dev/todomvc/");+await Expect(page).ToMatchAriaSnapshotAsync(@"+ - heading ""todos""+ - textbox ""What needs to be done?""+");+```++```java+page.navigate("https://demo.playwright.dev/todomvc/");+assertThat(page).matchesAriaSnapshot("""+ - heading "todos"+ - textbox "What needs to be done?"+""");+```++### param: PageAssertions.toMatchAriaSnapshot.expected+* since: v1.60+- `expected` <[string]>++### option: PageAssertions.toMatchAriaSnapshot.timeout = %%-js-assertions-timeout-%%+* since: v1.60++### option: PageAssertions.toMatchAriaSnapshot.timeout = %%-csharp-java-python-assertions-timeout-%%+* since: v1.60++## async method: PageAssertions.NotToMatchAriaSnapshot+* since: v1.60+* langs: python++The opposite of [`method: PageAssertions.toMatchAriaSnapshot`].++### param: PageAssertions.NotToMatchAriaSnapshot.expected+* since: v1.60+- `expected` <[string]>++### option: PageAssertions.NotToMatchAriaSnapshot.timeout = %%-csharp-java-python-assertions-timeout-%%+* since: v1.60++## async method: PageAssertions.toMatchAriaSnapshot#2+* since: v1.60+* langs: js++Asserts that the page body matches the given [accessibility snapshot](../aria-snapshots.md).++Snapshot is stored in a separate `.aria.yml` file in a location configured by `expect.toMatchAriaSnapshot.pathTemplate` and/or `snapshotPathTemplate` properties in the configuration file.++**Usage**++```js+await expect(page).toMatchAriaSnapshot();+await expect(page).toMatchAriaSnapshot({ name: 'home.aria.yml' });+```++### option: PageAssertions.toMatchAriaSnapshot#2.name+* since: v1.60+* langs: js+- `name` <[string]>++Name of the snapshot to store in the snapshot folder corresponding to this test.+Generates sequential names if not specified.++### option: PageAssertions.toMatchAriaSnapshot#2.timeout = %%-js-assertions-timeout-%%+* since: v1.60+## async method: PageAssertions.toHaveScreenshot#1* since: v1.23* langs: jsdiff --git a/docs/src/aria-snapshots.md b/docs/src/aria-snapshots.mdindex ad0ee92d74..851de7a730 100644--- a/docs/src/aria-snapshots.md+++ b/docs/src/aria-snapshots.md@@ -10,7 +10,7 @@ With Playwright's Snapshot testing you can assert the accessibility tree of a pa```jsawait page.goto('https://playwright.dev/');-await expect(page.getByRole('banner')).toMatchAriaSnapshot(`+await expect(page).toMatchAriaSnapshot(`- banner:- heading /Playwright enables reliable end-to-end/ [level=1]- link "Get started":@@ -23,7 +23,7 @@ await expect(page.getByRole('banner')).toMatchAriaSnapshot(````python syncpage.goto('https://playwright.dev/')-expect(page.query_selector('banner')).to_match_aria_snapshot("""+expect(page).to_match_aria_snapshot("""- banner:- heading /Playwright enables reliable end-to-end/ [level=1]- link "Get started":@@ -36,7 +36,7 @@ expect(page.query_selector('banner')).to_match_aria_snapshot("""```python asyncawait page.goto('https://playwright.dev/')-await expect(page.query_selector('banner')).to_match_aria_snapshot("""+await expect(page).to_match_aria_snapshot("""- banner:- heading /Playwright enables reliable end-to-end/ [level=1]- link "Get started":@@ -49,7 +49,7 @@ await expect(page.query_selector('banner')).to_match_aria_snapshot("""```javapage.navigate("https://playwright.dev/");-assertThat(page.locator("banner")).matchesAriaSnapshot("""+assertThat(page).matchesAriaSnapshot("""- banner:- heading /Playwright enables reliable end-to-end/ [level=1]- link "Get started":@@ -62,7 +62,7 @@ assertThat(page.locator("banner")).matchesAriaSnapshot("""```csharpawait page.GotoAsync("https://playwright.dev/");-await Expect(page.Locator("banner")).ToMatchAriaSnapshotAsync(@"+await Expect(page).ToMatchAriaSnapshotAsync(@"- banner:- heading ""Playwright enables reliable end-to-end testing for modern web apps."" [level=1]- link ""Get started"":@@ -164,9 +164,9 @@ structure of a page, use the [Chrome DevTools Accessibility Tab](https://develop## Snapshot matching-The [`method: LocatorAssertions.toMatchAriaSnapshot`] assertion method in Playwright compares the accessible-structure of the locator scope with a predefined aria snapshot template, helping validate the page's state against-testing requirements.+The [`method: PageAssertions.toMatchAriaSnapshot`] assertion method in Playwright compares the accessible+structure of the page with a predefined aria snapshot template, helping validate the page's state against+testing requirements. You can also use [`method: LocatorAssertions.toMatchAriaSnapshot`] to match a specific part of the page.For the following DOM:@@ -177,31 +177,31 @@ For the following DOM:You can match it using the following snapshot template:```js-await expect(page.locator('body')).toMatchAriaSnapshot(`+await expect(page).toMatchAriaSnapshot(`- heading "title"`);``````python sync-expect(page.locator("body")).to_match_aria_snapshot("""+expect(page).to_match_aria_snapshot("""- heading "title"""")``````python async-await expect(page.locator("body")).to_match_aria_snapshot("""+await expect(page).to_match_aria_snapshot("""- heading "title"""")``````java-assertThat(page.locator("body")).matchesAriaSnapshot("""+assertThat(page).matchesAriaSnapshot("""- heading "title"""");``````csharp-await Expect(page.Locator("body")).ToMatchAriaSnapshotAsync(@"+await Expect(page).ToMatchAriaSnapshotAsync(@"- heading ""title""");```@@ -418,35 +418,35 @@ export default defineConfig({});```-### Using the `Locator.ariaSnapshot` method+### Using [`method: Page.ariaSnapshot`] and [`method: Locator.ariaSnapshot`]-The [`method: Locator.ariaSnapshot`] method allows you to programmatically create a YAML representation of accessible+Methods [`method: Page.ariaSnapshot`] and [`method: Locator.ariaSnapshot`] allow you to programmatically create a YAML representation of accessibleelements within a locator's scope, especially helpful for generating snapshots dynamically during test execution.**Example**:```js-const snapshot = await page.locator('body').ariaSnapshot();+const snapshot = await page.ariaSnapshot();console.log(snapshot);``````python sync-snapshot = page.locator("body").aria_snapshot()+snapshot = page.aria_snapshot()print(snapshot)``````python async-snapshot = await page.locator("body").aria_snapshot()+snapshot = await page.aria_snapshot()print(snapshot)``````java-String snapshot = page.locator("body").ariaSnapshot();+String snapshot = page.ariaSnapshot();System.out.println(snapshot);``````csharp-var snapshot = await page.Locator("body").AriaSnapshotAsync();+var snapshot = await page.AriaSnapshotAsync();Console.WriteLine(snapshot);```diff --git a/docs/src/test-assertions-js.md b/docs/src/test-assertions-js.mdindex c809dce782..a1f2f8d727 100644--- a/docs/src/test-assertions-js.md+++ b/docs/src/test-assertions-js.md@@ -55,6 +55,7 @@ Note that retrying assertions are async, so you must `await` them.| [await expect(locator).toHaveValue()](./api/class-locatorassertions.md#locator-assertions-to-have-value) | Input has a value || [await expect(locator).toHaveValues()](./api/class-locatorassertions.md#locator-assertions-to-have-values) | Select has options selected || [await expect(locator).toMatchAriaSnapshot()](./api/class-locatorassertions.md#locator-assertions-to-match-aria-snapshot) | Element matches the Aria snapshot |+| [await expect(page).toMatchAriaSnapshot()](./api/class-pageassertions.md#page-assertions-to-match-aria-snapshot) | Page matches the Aria snapshot || [await expect(page).toHaveScreenshot()](./api/class-pageassertions.md#page-assertions-to-have-screenshot-1) | Page has a screenshot || [await expect(page).toHaveTitle()](./api/class-pageassertions.md#page-assertions-to-have-title) | Page has a title || [await expect(page).toHaveURL()](./api/class-pageassertions.md#page-assertions-to-have-url) | Page has a URL |diff --git a/packages/injected/src/injectedScript.ts b/packages/injected/src/injectedScript.tsindex a0882d2b05..732155168d 100644--- a/packages/injected/src/injectedScript.ts+++ b/packages/injected/src/injectedScript.ts@@ -1467,6 +1467,15 @@ export class InjectedScript {const received = this.document.location.href;return { received, matches: matcher.matches(received) };}+ if (options.expression === 'to.match.aria' && !options.selector) {+ if (!this.document.body)+ return { matches: options.isNot, missingReceived: true };+ const result = matchesExpectAriaTemplate(this.document.body, options.expectedValue);+ return {+ received: result.received,+ matches: !!result.matches.length,+ };+ }// When none of the above applies, expect does not match.return { matches: options.isNot, missingReceived: true };}diff --git a/packages/playwright/src/matchers/toMatchAriaSnapshot.ts b/packages/playwright/src/matchers/toMatchAriaSnapshot.tsindex 8212ad6623..f1959cf644 100644--- a/packages/playwright/src/matchers/toMatchAriaSnapshot.ts+++ b/packages/playwright/src/matchers/toMatchAriaSnapshot.ts@@ -20,12 +20,13 @@ import path from 'path';import { formatMatcherMessage, escapeTemplateString, isString, printReceivedStringContainExpectedSubstring } from 'playwright-core/lib/utils';-import { fileExistsAsync } from '../util';+import { expectTypes, fileExistsAsync } from '../util';import { currentTestInfo } from '../common/globals';import type { MatcherResult } from './matcherHint';-import type { ExpectMatcherStateInternal, LocatorEx } from './matchers';+import type { ExpectMatcherStateInternal, FrameEx, LocatorEx } from './matchers';import type { MatcherReceived } from '@injected/ariaSnapshot';+import type { Page } from 'playwright-core';type ToMatchAriaSnapshotExpected = {@@ -36,15 +37,17 @@ type ToMatchAriaSnapshotExpected = {export async function toMatchAriaSnapshot(this: ExpectMatcherStateInternal,- locator: LocatorEx,+ receiver: LocatorEx | Page,expectedParam?: ToMatchAriaSnapshotExpected,options: { timeout?: number } = {},): Promise<MatcherResult<string | RegExp, string>> {const matcherName = 'toMatchAriaSnapshot';+ expectTypes(receiver, ['Page', 'Locator'], matcherName);+ const locator = receiver.constructor.name === 'Page' ? undefined : receiver as LocatorEx;const testInfo = currentTestInfo();if (!testInfo)- throw new Error(`toMatchAriaSnapshot() must be called during the test`);+ throw new Error(`${matcherName}() must be called during the test`);if (testInfo._projectInternal.project.ignoreSnapshots)return { pass: !this.isNot, message: () => '', name: 'toMatchAriaSnapshot', expected: '' };@@ -85,7 +88,10 @@ export async function toMatchAriaSnapshot(if (globalChildren && !expected.match(/^- \/children:/m))expected = `- /children: ${globalChildren}\n` + expected;- const { matches: pass, received, log, timedOut, errorMessage } = await locator._expect('to.match.aria', { expectedValue: expected, isNot: this.isNot, timeout });+ const expectParams = { expectedValue: expected, isNot: this.isNot, timeout };+ const { matches: pass, received, log, timedOut, errorMessage } = locator ?+ await (locator as LocatorEx)._expect('to.match.aria', expectParams) :+ await ((receiver as Page).mainFrame() as FrameEx)._expect('to.match.aria', expectParams);const typedReceived = received as MatcherReceived;const message = () => {@@ -106,7 +112,7 @@ export async function toMatchAriaSnapshot(promise: this.promise,matcherName,expectation: 'expected',- locator: locator.toString(),+ locator: locator?.toString(),timeout,timedOut,printedExpected,diff --git a/packages/playwright/types/test.d.ts b/packages/playwright/types/test.d.tsindex 23e7e12e03..1f16509416 100644--- a/packages/playwright/types/test.d.ts+++ b/packages/playwright/types/test.d.ts@@ -9761,6 +9761,57 @@ interface PageAssertions {timeout?: number;}): Promise<void>;+ /**+ * Asserts that the page body matches the given [accessibility snapshot](https://playwright.dev/docs/aria-snapshots).+ *+ * **Usage**+ *+ * ```js+ * await page.goto('https://demo.playwright.dev/todomvc/');+ * await expect(page).toMatchAriaSnapshot(`+ * - heading "todos"+ * - textbox "What needs to be done?"+ * `);+ * ```+ *+ * @param expected+ * @param options+ */+ toMatchAriaSnapshot(expected: string, options?: {+ /**+ * Time to retry the assertion for in milliseconds. Defaults to `timeout` in `TestConfig.expect`.+ */+ timeout?: number;+ }): Promise<void>;++ /**+ * Asserts that the page body matches the given [accessibility snapshot](https://playwright.dev/docs/aria-snapshots).+ *+ * Snapshot is stored in a separate `.aria.yml` file in a location configured by+ * `expect.toMatchAriaSnapshot.pathTemplate` and/or `snapshotPathTemplate` properties in the configuration file.+ *+ * **Usage**+ *+ * ```js+ * await expect(page).toMatchAriaSnapshot();+ * await expect(page).toMatchAriaSnapshot({ name: 'home.aria.yml' });+ * ```+ *+ * @param options+ */+ toMatchAriaSnapshot(options?: {+ /**+ * Name of the snapshot to store in the snapshot folder corresponding to this test. Generates sequential names if not+ * specified.+ */+ name?: string;++ /**+ * Time to retry the assertion for in milliseconds. Defaults to `timeout` in `TestConfig.expect`.+ */+ timeout?: number;+ }): Promise<void>;+/*** Makes the assertion check for the opposite condition.*diff --git a/tests/library/trace-viewer.spec.ts b/tests/library/trace-viewer.spec.tsindex 1d8b64b994..2521936b40 100644--- a/tests/library/trace-viewer.spec.ts+++ b/tests/library/trace-viewer.spec.ts@@ -2022,7 +2022,7 @@ test('should render locator descriptions', async ({ runAndTrace, page }) => {await page.locator('input').describe('custom').first().click();});- await expect(traceViewer.page.locator('body')).toMatchAriaSnapshot(`+ await expect(traceViewer.page).toMatchAriaSnapshot(`- treeitem /Click.*custom/- treeitem /Click.*input.*first/`);@@ -2068,7 +2068,7 @@ test('should filter actions', async ({ runAndTrace, page }) => {await expect(traceViewer.page.getByText('3 hidden', { exact: true })).toBeVisible();await traceViewer.page.getByRole('button', { name: 'Filter actions' }).click();- await expect(traceViewer.page.getByTestId('actions-filter-dialog')).toMatchAriaSnapshot(`+ await expect(traceViewer.page).toMatchAriaSnapshot(`- dialog:- checkbox "Getters 1"- checkbox "Network routes 2"diff --git a/tests/page/to-match-aria-snapshot.spec.ts b/tests/page/to-match-aria-snapshot.spec.tsindex ebad90f49f..6e53068e29 100644--- a/tests/page/to-match-aria-snapshot.spec.ts+++ b/tests/page/to-match-aria-snapshot.spec.ts@@ -17,9 +17,52 @@import { stripAnsi } from '../config/utils';import { test, expect } from './pageTest';+test('should match page', async ({ page }) => {+ await page.setContent(`<h1>title</h1>`);+ await expect(page).toMatchAriaSnapshot(`+ - heading "title"+ `);+});++test('should match page complex', async ({ page }) => {+ await page.setContent(`+ <h1>Microsoft</h1>+ <div>Open source projects and samples from Microsoft</div>+ <ul>+ <li>+ <a href="about:blank">Playwright</a>+ </li>+ </ul>`);++ await expect(page).toMatchAriaSnapshot(`+ - heading "Microsoft"+ - text: Open source projects and samples from Microsoft+ - list:+ - listitem:+ - link "Playwright"+ `);+});++test('should match page with not', async ({ page }) => {+ await page.setContent(`<h1>title</h1>`);+ await expect(page).not.toMatchAriaSnapshot(`+ - heading "wrong"+ `);+});++test('should fail page with timeout', async ({ page }) => {+ await page.setContent(`<h1>title</h1>`);+ const e = await expect(page).toMatchAriaSnapshot(`+ - heading "wrong"+ `, { timeout: 2000 }).catch(e => e);+ expect(stripAnsi(e.message)).toContain('expect(page).toMatchAriaSnapshot(expected) failed');+ expect(stripAnsi(e.message)).toContain('Timeout: 2000ms');+ expect(stripAnsi(e.message)).not.toContain('Locator');+});+test('should match', async ({ page }) => {await page.setContent(`<h1>title</h1>`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- heading "title"`);});@@ -29,7 +72,7 @@ test('should match in list', async ({ page }) => {<h1>title</h1><h1>title 2</h1>`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- heading "title"`);});@@ -41,7 +84,7 @@ test('should match list with accessible name', async ({ page }) => {<li>two</li></ul>`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- list "my list":- listitem: "one"- listitem: "two"@@ -55,7 +98,7 @@ test('should match deep item', async ({ page }) => {<h1>title 2</h1></div>`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- heading "title"`);});@@ -68,7 +111,7 @@ test('should match complex', async ({ page }) => {</li></ul>`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- list:- listitem:- link "link"@@ -78,25 +121,25 @@ test('should match complex', async ({ page }) => {test('should match regex', async ({ page }) => {{await page.setContent(`<h1>Issues 12</h1>`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- heading ${/Issues \d+/}`);}{await page.setContent(`<h1>Issues 1/2</h1>`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- heading ${/Issues 1[/]2/}`);}{await page.setContent(`<h1>Issues 1[</h1>`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- heading ${/Issues 1\[/}`);}{await page.setContent(`<h1>Issues 1]]2</h1>`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- heading ${/Issues 1[\]]]2/}`);}@@ -108,7 +151,7 @@ test('should allow text nodes', async ({ page }) => {<div>Open source projects and samples from Microsoft</div>`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- heading "Microsoft"- text: "Open source projects and samples from Microsoft"`);@@ -122,7 +165,7 @@ test('details visibility', async ({ page }) => {</details>`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- group: "Summary"`);});@@ -132,36 +175,36 @@ test('checked attribute', async ({ page }) => {<input type='checkbox' checked />`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- checkbox`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- checkbox [checked]`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- checkbox [checked=true]`);{- const e = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const e = await expect(page).toMatchAriaSnapshot(`- checkbox [checked=false]`, { timeout: 1000 }).catch(e => e);- expect(stripAnsi(e.message)).toContain('expect(locator).toMatchAriaSnapshot(expected) failed');+ expect(stripAnsi(e.message)).toContain('expect(page).toMatchAriaSnapshot(expected) failed');expect(stripAnsi(e.message)).toContain('Timeout: 1000ms');}{- const e = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const e = await expect(page).toMatchAriaSnapshot(`- checkbox [checked=mixed]`, { timeout: 1000 }).catch(e => e);- expect(stripAnsi(e.message)).toContain('expect(locator).toMatchAriaSnapshot(expected) failed');+ expect(stripAnsi(e.message)).toContain('expect(page).toMatchAriaSnapshot(expected) failed');expect(stripAnsi(e.message)).toContain('Timeout: 1000ms');}{- const e = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const e = await expect(page).toMatchAriaSnapshot(`- checkbox [checked=5]`, { timeout: 1000 }).catch(e => e);expect(stripAnsi(e.message)).toContain(' attribute must be a boolean or "mixed"');@@ -173,28 +216,28 @@ test('disabled attribute', async ({ page }) => {<button disabled>Click me</button>`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- button`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- button [disabled]`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- button [disabled=true]`);{- const e = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const e = await expect(page).toMatchAriaSnapshot(`- button [disabled=false]`, { timeout: 1000 }).catch(e => e);- expect(stripAnsi(e.message)).toContain('expect(locator).toMatchAriaSnapshot(expected) failed');+ expect(stripAnsi(e.message)).toContain('expect(page).toMatchAriaSnapshot(expected) failed');expect(stripAnsi(e.message)).toContain('Timeout: 1000ms');}{- const e = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const e = await expect(page).toMatchAriaSnapshot(`- button [disabled=invalid]`, { timeout: 1000 }).catch(e => e);expect(stripAnsi(e.message)).toContain(' attribute must be a boolean');@@ -206,28 +249,28 @@ test('expanded attribute', async ({ page }) => {<button aria-expanded="true">Toggle</button>`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- button`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- button [expanded]`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- button [expanded=true]`);{- const e = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const e = await expect(page).toMatchAriaSnapshot(`- button [expanded=false]`, { timeout: 1000 }).catch(e => e);- expect(stripAnsi(e.message)).toContain('expect(locator).toMatchAriaSnapshot(expected) failed');+ expect(stripAnsi(e.message)).toContain('expect(page).toMatchAriaSnapshot(expected) failed');expect(stripAnsi(e.message)).toContain('Timeout: 1000ms');}{- const e = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const e = await expect(page).toMatchAriaSnapshot(`- button [expanded=invalid]`, { timeout: 1000 }).catch(e => e);expect(stripAnsi(e.message)).toContain(' attribute must be a boolean');@@ -239,24 +282,24 @@ test('level attribute', async ({ page }) => {<h2>Section Title</h2>`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- heading`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- heading [level=2]`);{- const e = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const e = await expect(page).toMatchAriaSnapshot(`- heading [level=3]`, { timeout: 1000 }).catch(e => e);- expect(stripAnsi(e.message)).toContain('expect(locator).toMatchAriaSnapshot(expected) failed');+ expect(stripAnsi(e.message)).toContain('expect(page).toMatchAriaSnapshot(expected) failed');expect(stripAnsi(e.message)).toContain('Timeout: 1000ms');}{- const e = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const e = await expect(page).toMatchAriaSnapshot(`- heading [level=two]`, { timeout: 1000 }).catch(e => e);expect(stripAnsi(e.message)).toContain(' attribute must be a number');@@ -268,23 +311,23 @@ test('pressed attribute', async ({ page }) => {<button aria-pressed="true">Like</button>`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- button`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- button [pressed]`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- button [pressed=true]`);{- const e = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const e = await expect(page).toMatchAriaSnapshot(`- button [pressed=false]`, { timeout: 1000 }).catch(e => e);- expect(stripAnsi(e.message)).toContain('expect(locator).toMatchAriaSnapshot(expected) failed');+ expect(stripAnsi(e.message)).toContain('expect(page).toMatchAriaSnapshot(expected) failed');expect(stripAnsi(e.message)).toContain('Timeout: 1000ms');}@@ -293,20 +336,20 @@ test('pressed attribute', async ({ page }) => {<button aria-pressed="mixed">Like</button>`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- button [pressed=mixed]`);{- const e = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const e = await expect(page).toMatchAriaSnapshot(`- button [pressed=true]`, { timeout: 1000 }).catch(e => e);- expect(stripAnsi(e.message)).toContain('expect(locator).toMatchAriaSnapshot(expected) failed');+ expect(stripAnsi(e.message)).toContain('expect(page).toMatchAriaSnapshot(expected) failed');expect(stripAnsi(e.message)).toContain('Timeout: 1000ms');}{- const e = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const e = await expect(page).toMatchAriaSnapshot(`- button [pressed=5]`, { timeout: 1000 }).catch(e => e);expect(stripAnsi(e.message)).toContain(' attribute must be a boolean or "mixed"');@@ -325,17 +368,17 @@ test('selected attribute', async ({ page }) => {</table>`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- row- row`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- row [selected]- row`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- row [selected=true]- row [selected=false]`);@@ -348,13 +391,12 @@ test('selected attribute', async ({ page }) => {`);{- const e = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const e = await expect(page).toMatchAriaSnapshot(`- row [selected=false]- row [selected=false]`, { timeout: 1000 }).catch(e => e);- expect(stripAnsi(e.message)).toContain(`expect(locator).toMatchAriaSnapshot(expected) failed+ expect(stripAnsi(e.message)).toContain(`expect(page).toMatchAriaSnapshot(expected) failed-Locator: locator('body')Timeout: 1000ms- Expected - 2+ Received + 6@@ -373,7 +415,7 @@ Call log:}{- const e = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const e = await expect(page).toMatchAriaSnapshot(`- row [selected=invalid]`, { timeout: 1000 }).catch(e => e);expect(stripAnsi(e.message)).toContain(' attribute must be a boolean');@@ -414,7 +456,7 @@ test('integration test', async ({ page }) => {</li></ul>`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- heading "Microsoft"- text: Open source projects and samples from Microsoft- list:@@ -433,7 +475,7 @@ test('integration test 2', async ({ page }) => {<input placeholder="What needs to be done?"></header></div>`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- heading "todos"- textbox "What needs to be done?"`);@@ -448,16 +490,15 @@ test('expected formatter', async ({ page }) => {<button>Time 15:30</button></header></div>`);- const error = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const error = await expect(page).toMatchAriaSnapshot(`- heading "todos"- textbox "Wrong text"`, { timeout: 1 }).catch(e => e);// Note that error message should not contain any regular expressions,// unlike the baseline generated by --update-snapshots.- expect(stripAnsi(error.message)).toContain(`expect(locator).toMatchAriaSnapshot(expected) failed+ expect(stripAnsi(error.message)).toContain(`expect(page).toMatchAriaSnapshot(expected) failed-Locator: locator('body')Timeout: 1ms- Expected - 2+ Received + 4@@ -478,10 +519,10 @@ test('should unpack escaped names', async ({ page }) => {await page.setContent(`<button>Click: me</button>`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- 'button "Click: me"'`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- 'button /Click: me/'`);}@@ -490,13 +531,13 @@ test('should unpack escaped names', async ({ page }) => {await page.setContent(`<button>Click / me</button>`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- button "Click / me"`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- button /Click \\/ me/`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- 'button /Click \\/ me/'`);}@@ -505,13 +546,13 @@ test('should unpack escaped names', async ({ page }) => {await page.setContent(`<button>Click " me</button>`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- button "Click \\\" me"`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- button /Click \" me/`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- button /Click \\\" me/`);}@@ -520,13 +561,13 @@ test('should unpack escaped names', async ({ page }) => {await page.setContent(`<button>Click \\ me</button>`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- button "Click \\\\ me"`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- button /Click \\\\ me/`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- 'button /Click \\\\ me/'`);}@@ -535,7 +576,7 @@ test('should unpack escaped names', async ({ page }) => {await page.setContent(`<button>Click ' me</button>`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- 'button "Click '' me"'`);}@@ -544,7 +585,7 @@ test('should unpack escaped names', async ({ page }) => {await page.setContent(`<h1>heading "name" [level=1]</h1>`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- heading "heading \\"name\\" [level=1]" [level=1]`);}@@ -553,7 +594,7 @@ test('should unpack escaped names', async ({ page }) => {await page.setContent(`<h1>heading \\" [level=2]</h1>`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- |heading "heading \\\\\\" [level=2]" [level = 1 ]@@ -565,14 +606,14 @@ test('should report error in YAML', async ({ page }) => {await page.setContent(`<h1>title</h1>`);{- const error = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const error = await expect(page).toMatchAriaSnapshot(`heading "title"`).catch(e => e);expect.soft(error.message).toBe(`expect.toMatchAriaSnapshot: Aria snapshot must be a YAML sequence, elements starting with " -"`);}{- const error = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const error = await expect(page).toMatchAriaSnapshot(`- heading: a:`).catch(e => e);expect.soft(error.message).toBe(`expect.toMatchAriaSnapshot: Nested mappings are not allowed in compact mappings at line 1, column 12:@@ -587,7 +628,7 @@ test('should report error in YAML keys', async ({ page }) => {await page.setContent(`<h1>title</h1>`);{- const error = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const error = await expect(page).toMatchAriaSnapshot(`- heading "title`).catch(e => e);expect.soft(error.message).toBe(`expect.toMatchAriaSnapshot: Unterminated string:@@ -598,7 +639,7 @@ heading "title}{- const error = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const error = await expect(page).toMatchAriaSnapshot(`- heading /title`).catch(e => e);expect.soft(error.message).toBe(`expect.toMatchAriaSnapshot: Unterminated regex:@@ -609,7 +650,7 @@ heading /title}{- const error = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const error = await expect(page).toMatchAriaSnapshot(`- heading [level=a]`).catch(e => e);expect.soft(error.message).toBe(`expect.toMatchAriaSnapshot: Value of "level" attribute must be a number:@@ -620,7 +661,7 @@ heading [level=a]}{- const error = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const error = await expect(page).toMatchAriaSnapshot(`- heading [expanded=FALSE]`).catch(e => e);expect.soft(error.message).toBe(`expect.toMatchAriaSnapshot: Value of "expanded" attribute must be a boolean:@@ -631,7 +672,7 @@ heading [expanded=FALSE]}{- const error = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const error = await expect(page).toMatchAriaSnapshot(`- heading [checked=foo]`).catch(e => e);expect.soft(error.message).toBe(`expect.toMatchAriaSnapshot: Value of "checked" attribute must be a boolean or "mixed":@@ -642,7 +683,7 @@ heading [checked=foo]}{- const error = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const error = await expect(page).toMatchAriaSnapshot(`- heading [level=]`).catch(e => e);expect.soft(error.message).toBe(`expect.toMatchAriaSnapshot: Value of "level" attribute must be a number:@@ -653,7 +694,7 @@ heading [level=]}{- const error = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const error = await expect(page).toMatchAriaSnapshot(`- heading [bogus]`).catch(e => e);expect.soft(error.message).toBe(`expect.toMatchAriaSnapshot: Unsupported attribute [bogus]:@@ -664,7 +705,7 @@ heading [bogus]}{- const error = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const error = await expect(page).toMatchAriaSnapshot(`- heading invalid`).catch(e => e);expect.soft(error.message).toBe(`expect.toMatchAriaSnapshot: Unexpected input:@@ -677,11 +718,11 @@ heading invalidtest('call log should contain actual snapshot', async ({ page }) => {await page.setContent(`<h1>todos</h1>`);- const error = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const error = await expect(page).toMatchAriaSnapshot(`- heading "wrong"`, { timeout: 3000 }).catch(e => e);- expect(stripAnsi(error.message)).toContain(`- unexpected value "- heading "todos" [level=1]"`);+ expect(stripAnsi(error.message)).toContain(`unexpected value "- heading "todos" [level=1]"`);});test('should parse attributes', async ({ page }) => {@@ -689,7 +730,7 @@ test('should parse attributes', async ({ page }) => {await page.setContent(`<button aria-pressed="mixed">hello world</button>`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- button [pressed=mixed ]`);}@@ -709,7 +750,7 @@ test('should not unshift actual template text', async ({ page }) => {<h1>title</h1><h1>title 2</h1>`);- const error = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const error = await expect(page).toMatchAriaSnapshot(`- heading "title" [level=1]- heading "title 2" [level=1]`, { timeout: 1000 }).catch(e => e);@@ -720,7 +761,7 @@ test('should not unshift actual template text', async ({ page }) => {test('should not match what is not matched', async ({ page }) => {await page.setContent(`<p>Text</p>`);- const error = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const error = await expect(page).toMatchAriaSnapshot(`- paragraph:- button "bogus"`).catch(e => e);@@ -735,7 +776,7 @@ test('should match url', async ({ page }) => {<a href='https://example.com'>Link</a>`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- link:- /url: /.*example.com/`);@@ -750,20 +791,20 @@ test('should detect unexpected children: equal', async ({ page }) => {</ul>`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- list:- listitem: "One"- listitem: "Three"`);- const e = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const e = await expect(page).toMatchAriaSnapshot(`- list:- /children: equal- listitem: "One"- listitem: "Three"`, { timeout: 1000 }).catch(e => e);- expect(stripAnsi(e.message)).toContain('expect(locator).toMatchAriaSnapshot(expected) failed');+ expect(stripAnsi(e.message)).toContain('expect(page).toMatchAriaSnapshot(expected) failed');expect(stripAnsi(e.message)).toContain('+ - listitem: Two');});@@ -779,14 +820,14 @@ test('should detect unexpected children: deep-equal', async ({ page }) => {</ul>`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- list:- listitem:- list:- listitem: 1.1`);- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- list:- /children: equal- listitem:@@ -794,7 +835,7 @@ test('should detect unexpected children: deep-equal', async ({ page }) => {- listitem: 1.1`);- const e = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const e = await expect(page).toMatchAriaSnapshot(`- list:- /children: deep-equal- listitem:@@ -802,7 +843,7 @@ test('should detect unexpected children: deep-equal', async ({ page }) => {- listitem: 1.1`, { timeout: 1000 }).catch(e => e);- expect(stripAnsi(e.message)).toContain('expect(locator).toMatchAriaSnapshot(expected) failed');+ expect(stripAnsi(e.message)).toContain('expect(page).toMatchAriaSnapshot(expected) failed');expect(stripAnsi(e.message)).toContain('+ - listitem: \"1.2\"');});@@ -818,7 +859,7 @@ test('should allow restoring contain mode inside deep-equal', async ({ page }) =</ul>`);- const e = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const e = await expect(page).toMatchAriaSnapshot(`- list:- /children: deep-equal- listitem:@@ -826,10 +867,10 @@ test('should allow restoring contain mode inside deep-equal', async ({ page }) =- listitem: 1.1`, { timeout: 1000 }).catch(e => e);- expect(stripAnsi(e.message)).toContain('expect(locator).toMatchAriaSnapshot(expected) failed');+ expect(stripAnsi(e.message)).toContain('expect(page).toMatchAriaSnapshot(expected) failed');expect(stripAnsi(e.message)).toContain('+ - listitem: \"1.2\"');- await expect(page.locator('body')).toMatchAriaSnapshot(`+ await expect(page).toMatchAriaSnapshot(`- list:- /children: deep-equal- listitem:@@ -851,7 +892,7 @@ test('top-level deep-equal', { annotation: { type: 'issue', description: 'https:</ul>`);- const error = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const error = await expect(page).toMatchAriaSnapshot(`- /children: deep-equal- list`, { timeout: 1000 }).catch(e => e);@@ -870,11 +911,11 @@ test('top-level deep-equal', { annotation: { type: 'issue', description: 'https:test('treat bad regex as a string', async ({ page }) => {await page.setContent(`<a href="/foo">Log in</a>`);- const error = await expect(page.locator('body')).toMatchAriaSnapshot(`+ const error = await expect(page).toMatchAriaSnapshot(`- link "Log in":- /url: /[a/`, { timeout: 1 }).catch(e => e);- expect(stripAnsi(error.message)).toContain('expect(locator).toMatchAriaSnapshot(expected) failed');+ expect(stripAnsi(error.message)).toContain('expect(page).toMatchAriaSnapshot(expected) failed');expect(stripAnsi(error.message)).toContain('- - /url: /[a/');expect(stripAnsi(error.message)).toContain('+ - /url: /foo');});diff --git a/tests/playwright-test/aria-snapshot-file.spec.ts b/tests/playwright-test/aria-snapshot-file.spec.tsindex ded73bcc3c..53960ea395 100644--- a/tests/playwright-test/aria-snapshot-file.spec.ts+++ b/tests/playwright-test/aria-snapshot-file.spec.ts@@ -29,7 +29,7 @@ test('should match snapshot with name', async ({ runInlineTest }, testInfo) => {import { test, expect } from '@playwright/test';test('test', async ({ page }) => {await page.setContent(\`<h1>hello world</h1>\`);- await expect(page.locator('body')).toMatchAriaSnapshot({ name: 'test.aria.yml' });+ await expect(page).toMatchAriaSnapshot({ name: 'test.aria.yml' });});`});@@ -43,9 +43,9 @@ test('should generate multiple missing', async ({ runInlineTest }, testInfo) =>import { test, expect } from '@playwright/test';test('test', async ({ page }) => {await page.setContent(\`<h1>hello world</h1>\`);- await expect(page.locator('body')).toMatchAriaSnapshot({ name: 'test-1.aria.yml' });+ await expect(page).toMatchAriaSnapshot({ name: 'test-1.aria.yml' });await page.setContent(\`<h1>hello world 2</h1>\`);- await expect(page.locator('body')).toMatchAriaSnapshot({ name: 'test-2.aria.yml' });+ await expect(page).toMatchAriaSnapshot({ name: 'test-2.aria.yml' });});`});@@ -71,9 +71,9 @@ test('should rebaseline all', async ({ runInlineTest }, testInfo) => {import { test, expect } from '@playwright/test';test('test', async ({ page }) => {await page.setContent(\`<h1>hello world</h1>\`);- await expect(page.locator('body')).toMatchAriaSnapshot({ name: 'test-1.aria.yml' });+ await expect(page).toMatchAriaSnapshot({ name: 'test-1.aria.yml' });await page.setContent(\`<h1>hello world 2</h1>\`);- await expect(page.locator('body')).toMatchAriaSnapshot({ name: 'test-2.aria.yml' });+ await expect(page).toMatchAriaSnapshot({ name: 'test-2.aria.yml' });});`}, { 'update-snapshots': 'all' });@@ -96,7 +96,7 @@ test('should not rebaseline matching', async ({ runInlineTest }, testInfo) => {import { test, expect } from '@playwright/test';test('test', async ({ page }) => {await page.setContent(\`<h1>hello world</h1>\`);- await expect(page.locator('body')).toMatchAriaSnapshot({ name: 'test.aria.yml' });+ await expect(page).toMatchAriaSnapshot({ name: 'test.aria.yml' });});`}, { 'update-snapshots': 'changed' });@@ -112,9 +112,9 @@ test('should generate snapshot name', async ({ runInlineTest }, testInfo) => {import { test, expect } from '@playwright/test';test('test name', async ({ page }) => {await page.setContent(\`<h1>hello world</h1>\`);- await expect(page.locator('body')).toMatchAriaSnapshot();+ await expect(page).toMatchAriaSnapshot();await page.setContent(\`<h1>hello world 2</h1>\`);- await expect(page.locator('body')).toMatchAriaSnapshot();+ await expect(page).toMatchAriaSnapshot();});`});diff --git a/tests/playwright-test/update-aria-snapshot.spec.ts b/tests/playwright-test/update-aria-snapshot.spec.tsindex 203b5c27e4..ae11bfcaf3 100644--- a/tests/playwright-test/update-aria-snapshot.spec.ts+++ b/tests/playwright-test/update-aria-snapshot.spec.ts@@ -34,7 +34,7 @@ test('should update snapshot with the update-snapshots flag with multiple projecimport { test, expect } from '@playwright/test';test('test', async ({ page }) => {await page.setContent(\`<h1>hello</h1><h2>bye</h2>\`);- await expect(page.locator('body')).toMatchAriaSnapshot(\`+ await expect(page).toMatchAriaSnapshot(\`- heading "world"\`);});@@ -50,7 +50,7 @@ test('should update snapshot with the update-snapshots flag with multiple projec@@ -3,7 +3,8 @@test('test', async ({ page }) => {await page.setContent(\`<h1>hello</h1><h2>bye</h2>\`);- await expect(page.locator('body')).toMatchAriaSnapshot(\`+ await expect(page).toMatchAriaSnapshot(\`- - heading "world"+ - heading "hello" [level=1]+ - heading "bye" [level=2]@@ -79,7 +79,7 @@ test('should update missing snapshots', async ({ runInlineTest }, testInfo) => {import { test, expect } from '@playwright/test';test('test', async ({ page }) => {await page.setContent(\`<h1>hello</h1>\`);- await expect(page.locator('body')).toMatchAriaSnapshot(\`\`);+ await expect(page).toMatchAriaSnapshot(\`\`);});`});@@ -103,8 +103,8 @@ test('should update missing snapshots', async ({ runInlineTest }, testInfo) => {import { test, expect } from '@playwright/test';test('test', async ({ page }) => {await page.setContent(\`<h1>hello</h1>\`);-- await expect(page.locator('body')).toMatchAriaSnapshot(\`\`);-+ await expect(page.locator('body')).toMatchAriaSnapshot(\`+- await expect(page).toMatchAriaSnapshot(\`\`);++ await expect(page).toMatchAriaSnapshot(\`+ - heading "hello" [level=1]+ \`);});@@ -124,8 +124,8 @@ test('should update multiple missing snapshots', async ({ runInlineTest }, testIimport { test, expect } from '@playwright/test';test('test', async ({ page }) => {await page.setContent(\`<h1>hello</h1>\`);- await expect(page.locator('body')).toMatchAriaSnapshot(\`\`);- await expect(page.locator('body')).toMatchAriaSnapshot(\`\`);+ await expect(page).toMatchAriaSnapshot(\`\`);+ await expect(page).toMatchAriaSnapshot(\`\`);});`});@@ -148,12 +148,12 @@ test('should update multiple missing snapshots', async ({ runInlineTest }, testIimport { test, expect } from '@playwright/test';test('test', async ({ page }) => {await page.setContent(\`<h1>hello</h1>\`);-- await expect(page.locator('body')).toMatchAriaSnapshot(\`\`);-- await expect(page.locator('body')).toMatchAriaSnapshot(\`\`);-+ await expect(page.locator('body')).toMatchAriaSnapshot(\`+- await expect(page).toMatchAriaSnapshot(\`\`);+- await expect(page).toMatchAriaSnapshot(\`\`);++ await expect(page).toMatchAriaSnapshot(\`+ - heading "hello" [level=1]+ \`);-+ await expect(page.locator('body')).toMatchAriaSnapshot(\`++ await expect(page).toMatchAriaSnapshot(\`+ - heading "hello" [level=1]+ \`);});@@ -549,7 +549,7 @@ test.describe('update-snapshots all', () => {import { test, expect } from '@playwright/test';test('test', async ({ page }) => {await page.setContent(\`<h1>hello</h1><h1>world</h1>\`);- await expect(page.locator('body')).toMatchAriaSnapshot(\`+ await expect(page).toMatchAriaSnapshot(\`- heading "hello"\`);});@@ -565,7 +565,7 @@ test.describe('update-snapshots all', () => {@@ -3,7 +3,8 @@test('test', async ({ page }) => {await page.setContent(\`<h1>hello</h1><h1>world</h1>\`);- await expect(page.locator('body')).toMatchAriaSnapshot(\`+ await expect(page).toMatchAriaSnapshot(\`- - heading "hello"+ - heading "hello" [level=1]+ - heading "world" [level=1]