Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,11 @@ export default ({ mode }: { mode: string }) => {
link: '/guide/browser/trace-view',
docFooterText: '追踪查看器 | 浏览器模式',
},
{
text: 'ARIA Snapshots',
link: '/guide/browser/aria-snapshots',
docFooterText: 'ARIA Snapshots | Browser Mode',
},
],
},
{
Expand Down
37 changes: 37 additions & 0 deletions api/expect.md
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,43 @@ it('render basic', async () => {
- **类型:** `(snapshot?: string, hint?: string) => void`

与 [`toMatchInlineSnapshot`](#tomatchinlinesnapshot) 类似,但期望的值与 [`toThrow`](#toThrow) 相同。
<!-- TODO: translation -->
## toMatchAriaSnapshot <Version type="experimental">4.1.4</Version> <Experimental /> {#tomatcharisnapshot}

- **Type:** `() => void`

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.

```ts
import { expect, test } from 'vitest'

test('navigation accessibility', () => {
document.body.innerHTML = `
<nav aria-label="Actions">
<button>Save</button>
<button>Cancel</button>
</nav>
`
expect(document.querySelector('nav')).toMatchAriaSnapshot()
})
```

## toMatchAriaInlineSnapshot <Version type="experimental">4.1.4</Version> <Experimental /> {#tomatchariainlinesnapshot}

- **Type:** `(snapshot?: string) => void`

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.

```ts
import { expect, test } from 'vitest'

test('user profile', () => {
expect(document.body).toMatchAriaInlineSnapshot(`
- heading "Dashboard" [level=1]
- button /User \\d+/: Profile
`)
})
```

## toHaveBeenCalled

Expand Down
Loading
Loading