Skip to content

Commit d4fbb5c

Browse files
hi-ogawaclaudeAriPerkkiocodexsheremet-va
authored
feat(experimental): support aria snapshot (#9668)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Ari Perkkiö <ari.perkkio@gmail.com> Co-authored-by: Codex <noreply@openai.com> Co-authored-by: Vladimir <sleuths.slews0s@icloud.com>
1 parent b77de96 commit d4fbb5c

File tree

52 files changed

+4067
-170
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+4067
-170
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ jobs:
120120
- name: Test Examples
121121
run: pnpm run test:examples
122122

123+
- name: Unit Test UI
124+
run: pnpm -C packages/ui test:ui
125+
123126
- uses: actions/upload-artifact@v7
124127
if: ${{ !cancelled() }}
125128
with:

docs/.vitepress/config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,11 @@ export default ({ mode }: { mode: string }) => {
806806
link: '/guide/browser/trace-view',
807807
docFooterText: 'Trace View | Browser Mode',
808808
},
809+
{
810+
text: 'ARIA Snapshots',
811+
link: '/guide/browser/aria-snapshots',
812+
docFooterText: 'ARIA Snapshots | Browser Mode',
813+
},
809814
],
810815
},
811816
{

docs/api/expect.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,43 @@ The same as [`toMatchSnapshot`](#tomatchsnapshot), but expects the same value as
10101010

10111011
The same as [`toMatchInlineSnapshot`](#tomatchinlinesnapshot), but expects the same value as [`toThrow`](#tothrow).
10121012

1013+
## toMatchAriaSnapshot <Version type="experimental">4.1.4</Version> <Experimental /> {#tomatcharisnapshot}
1014+
1015+
- **Type:** `() => void`
1016+
1017+
Captures the accessibility tree of a DOM element and generate a snapshot file or compares it against a stored snapshot. See the [ARIA Snapshots guide](/guide/browser/aria-snapshots) for more details.
1018+
1019+
```ts
1020+
import { expect, test } from 'vitest'
1021+
1022+
test('navigation accessibility', () => {
1023+
document.body.innerHTML = `
1024+
<nav aria-label="Actions">
1025+
<button>Save</button>
1026+
<button>Cancel</button>
1027+
</nav>
1028+
`
1029+
expect(document.querySelector('nav')).toMatchAriaSnapshot()
1030+
})
1031+
```
1032+
1033+
## toMatchAriaInlineSnapshot <Version type="experimental">4.1.4</Version> <Experimental /> {#tomatchariainlinesnapshot}
1034+
1035+
- **Type:** `(snapshot?: string) => void`
1036+
1037+
Same as [`toMatchAriaSnapshot`](#tomatcharisnapshot), but stores the snapshot inline in the test file. See the [ARIA Snapshots guide](/guide/browser/aria-snapshots) for more details.
1038+
1039+
```ts
1040+
import { expect, test } from 'vitest'
1041+
1042+
test('user profile', () => {
1043+
expect(document.body).toMatchAriaInlineSnapshot(`
1044+
- heading "Dashboard" [level=1]
1045+
- button /User \\d+/: Profile
1046+
`)
1047+
})
1048+
```
1049+
10131050
## toHaveBeenCalled
10141051

10151052
- **Type:** `() => Awaitable<void>`

0 commit comments

Comments
 (0)