From 9970446f517e0562b543a032c62ce5fe8ae78cbb Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Fri, 17 Jan 2025 14:35:15 -0800 Subject: [PATCH] chore: remove toMatchAriaSnapshot.path (#34379) --- docs/src/api/class-locatorassertions.md | 9 ++------- .../src/matchers/toMatchAriaSnapshot.ts | 4 +--- packages/playwright/types/test.d.ts | 9 ++------- .../playwright-test/aria-snapshot-file.spec.ts | 18 ------------------ 4 files changed, 5 insertions(+), 35 deletions(-) diff --git a/docs/src/api/class-locatorassertions.md b/docs/src/api/class-locatorassertions.md index 63b487208f491..35f64ea71175c 100644 --- a/docs/src/api/class-locatorassertions.md +++ b/docs/src/api/class-locatorassertions.md @@ -2274,13 +2274,8 @@ assertThat(page.locator("body")).matchesAriaSnapshot(new LocatorAssertions.Match * langs: js - `name` <[string]> -Name of the snapshot to store in the snapshot folder corresponding to this test. Generates ordinal name if not specified. - -### option: LocatorAssertions.toMatchAriaSnapshot#2.path -* since: v1.50 -- `path` <[string]> - -Path to the YAML snapshot file. +Name of the snapshot to store in the snapshot (screenshot) folder corresponding to this test. +Generates sequential names if not specified. ### option: LocatorAssertions.toMatchAriaSnapshot#2.timeout = %%-js-assertions-timeout-%% * since: v1.50 diff --git a/packages/playwright/src/matchers/toMatchAriaSnapshot.ts b/packages/playwright/src/matchers/toMatchAriaSnapshot.ts index 152ceb6ba90fd..c291770fd5619 100644 --- a/packages/playwright/src/matchers/toMatchAriaSnapshot.ts +++ b/packages/playwright/src/matchers/toMatchAriaSnapshot.ts @@ -59,9 +59,7 @@ export async function toMatchAriaSnapshot( if (isString(expectedParam)) { expected = expectedParam; } else { - if (expectedParam?.path) { - expectedPath = expectedParam.path; - } else if (expectedParam?.name) { + if (expectedParam?.name) { expectedPath = testInfo.snapshotPath(sanitizeFilePathBeforeExtension(expectedParam.name)); } else { let snapshotNames = (testInfo as any)[snapshotNamesSymbol] as SnapshotNames; diff --git a/packages/playwright/types/test.d.ts b/packages/playwright/types/test.d.ts index e01271ceec475..b67377eb6df21 100644 --- a/packages/playwright/types/test.d.ts +++ b/packages/playwright/types/test.d.ts @@ -8697,16 +8697,11 @@ interface LocatorAssertions { */ toMatchAriaSnapshot(options?: { /** - * Name of the snapshot to store in the snapshot folder corresponding to this test. Generates ordinal name if not - * specified. + * Name of the snapshot to store in the snapshot (screenshot) folder corresponding to this test. Generates sequential + * names if not specified. */ name?: string; - /** - * Path to the YAML snapshot file. - */ - path?: string; - /** * Time to retry the assertion for in milliseconds. Defaults to `timeout` in `TestConfig.expect`. */ diff --git a/tests/playwright-test/aria-snapshot-file.spec.ts b/tests/playwright-test/aria-snapshot-file.spec.ts index c05ae3897d9a1..18ebc072cca24 100644 --- a/tests/playwright-test/aria-snapshot-file.spec.ts +++ b/tests/playwright-test/aria-snapshot-file.spec.ts @@ -42,24 +42,6 @@ test('should match snapshot with name', async ({ runInlineTest }, testInfo) => { expect(result.exitCode).toBe(0); }); -test('should match snapshot with path', async ({ runInlineTest }, testInfo) => { - const result = await runInlineTest({ - 'test.yml': ` - - heading "hello world" - `, - 'a.spec.ts': ` - import { test, expect } from '@playwright/test'; - import path from 'path'; - test('test', async ({ page }) => { - await page.setContent(\`

hello world

\`); - await expect(page.locator('body')).toMatchAriaSnapshot({ path: path.resolve(__dirname, 'test.yml') }); - }); - ` - }); - - expect(result.exitCode).toBe(0); -}); - test('should generate multiple missing', async ({ runInlineTest }, testInfo) => { const result = await runInlineTest({ 'playwright.config.ts': `