chore: remove toMatchAriaSnapshot.path (#34379)

This commit is contained in:
Pavel Feldman 2025-01-17 14:35:15 -08:00 committed by GitHub
parent d082805ea9
commit 9970446f51
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 5 additions and 35 deletions

View File

@ -2274,13 +2274,8 @@ assertThat(page.locator("body")).matchesAriaSnapshot(new LocatorAssertions.Match
* langs: js * langs: js
- `name` <[string]> - `name` <[string]>
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.
### option: LocatorAssertions.toMatchAriaSnapshot#2.path
* since: v1.50
- `path` <[string]>
Path to the YAML snapshot file.
### option: LocatorAssertions.toMatchAriaSnapshot#2.timeout = %%-js-assertions-timeout-%% ### option: LocatorAssertions.toMatchAriaSnapshot#2.timeout = %%-js-assertions-timeout-%%
* since: v1.50 * since: v1.50

View File

@ -59,9 +59,7 @@ export async function toMatchAriaSnapshot(
if (isString(expectedParam)) { if (isString(expectedParam)) {
expected = expectedParam; expected = expectedParam;
} else { } else {
if (expectedParam?.path) { if (expectedParam?.name) {
expectedPath = expectedParam.path;
} else if (expectedParam?.name) {
expectedPath = testInfo.snapshotPath(sanitizeFilePathBeforeExtension(expectedParam.name)); expectedPath = testInfo.snapshotPath(sanitizeFilePathBeforeExtension(expectedParam.name));
} else { } else {
let snapshotNames = (testInfo as any)[snapshotNamesSymbol] as SnapshotNames; let snapshotNames = (testInfo as any)[snapshotNamesSymbol] as SnapshotNames;

View File

@ -8697,16 +8697,11 @@ interface LocatorAssertions {
*/ */
toMatchAriaSnapshot(options?: { toMatchAriaSnapshot(options?: {
/** /**
* Name of the snapshot to store in the snapshot folder corresponding to this test. Generates ordinal name if not * Name of the snapshot to store in the snapshot (screenshot) folder corresponding to this test. Generates sequential
* specified. * names if not specified.
*/ */
name?: string; name?: string;
/**
* Path to the YAML snapshot file.
*/
path?: string;
/** /**
* Time to retry the assertion for in milliseconds. Defaults to `timeout` in `TestConfig.expect`. * Time to retry the assertion for in milliseconds. Defaults to `timeout` in `TestConfig.expect`.
*/ */

View File

@ -42,24 +42,6 @@ test('should match snapshot with name', async ({ runInlineTest }, testInfo) => {
expect(result.exitCode).toBe(0); 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(\`<h1>hello world</h1>\`);
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) => { test('should generate multiple missing', async ({ runInlineTest }, testInfo) => {
const result = await runInlineTest({ const result = await runInlineTest({
'playwright.config.ts': ` 'playwright.config.ts': `