Skip to content

[Feature]: Add aria snapshot raw saving #38074

@vincenzo-gasparo

Description

@vincenzo-gasparo

🚀 Feature Request

As a user I want to have an option that allows to save generated aria snapshot .yml files in raw mode, without generating regular expressions.

Example

Should save aria snapshot in raw mode:

      import { test, expect } from '@playwright/test';
      import fs from 'fs';
      test('test', async ({ page }) => {
        await page.setContent(\`<h1>hello world 123</h1>\`);
        await expect(page.locator('body')).toMatchAriaSnapshot({ name: 'test.aria.yml', exact: true });
        expect(fs.readFileSync('a.spec.ts-snapshots/test.aria.yml', {encoding: 'utf8'})).toEqual('- heading "hello world 123" [level=1]');
      });

Should save aria snapshot in regex mode:

      import { test, expect } from '@playwright/test';
      import fs from 'fs';
      test('test', async ({ page }) => {
        await page.setContent(\`<h1>hello world 123</h1>\`);
        await expect(page.locator('body')).toMatchAriaSnapshot({ name: 'test.aria.yml', exact: false });
        expect(fs.readFileSync('a.spec.ts-snapshots/test.aria.yml', {encoding: 'utf8'})).toEqual('- heading /hello world \\d+/ [level=1]');
      });

Motivation

Sometimes I need to check exact values (data calculation or mocked data) and this is the fastest way to achieve the result

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions