Skip to content

Commit c42cdf2

Browse files
authored
Merge pull request #959 from vitest-dev/sync-5755951b-1
docs(en): merge docs-cn/sync-docs into docs-cn/dev @ 5755951
2 parents f286921 + a0f73c7 commit c42cdf2

5 files changed

Lines changed: 769 additions & 1 deletion

File tree

.vitepress/config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,11 @@ export default ({ mode }: { mode: string }) => {
807807
link: '/guide/browser/trace-view',
808808
docFooterText: '追踪查看器 | 浏览器模式',
809809
},
810+
{
811+
text: 'ARIA Snapshots',
812+
link: '/guide/browser/aria-snapshots',
813+
docFooterText: 'ARIA Snapshots | Browser Mode',
814+
},
810815
],
811816
},
812817
{

api/expect.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,43 @@ it('render basic', async () => {
10111011
- **类型:** `(snapshot?: string, hint?: string) => void`
10121012

10131013
[`toMatchInlineSnapshot`](#tomatchinlinesnapshot) 类似,但期望的值与 [`toThrow`](#toThrow) 相同。
1014+
<!-- TODO: translation -->
1015+
## toMatchAriaSnapshot <Version type="experimental">4.1.4</Version> <Experimental /> {#tomatcharisnapshot}
1016+
1017+
- **Type:** `() => void`
1018+
1019+
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.
1020+
1021+
```ts
1022+
import { expect, test } from 'vitest'
1023+
1024+
test('navigation accessibility', () => {
1025+
document.body.innerHTML = `
1026+
<nav aria-label="Actions">
1027+
<button>Save</button>
1028+
<button>Cancel</button>
1029+
</nav>
1030+
`
1031+
expect(document.querySelector('nav')).toMatchAriaSnapshot()
1032+
})
1033+
```
1034+
1035+
## toMatchAriaInlineSnapshot <Version type="experimental">4.1.4</Version> <Experimental /> {#tomatchariainlinesnapshot}
1036+
1037+
- **Type:** `(snapshot?: string) => void`
1038+
1039+
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.
1040+
1041+
```ts
1042+
import { expect, test } from 'vitest'
1043+
1044+
test('user profile', () => {
1045+
expect(document.body).toMatchAriaInlineSnapshot(`
1046+
- heading "Dashboard" [level=1]
1047+
- button /User \\d+/: Profile
1048+
`)
1049+
})
1050+
```
10141051

10151052
## toHaveBeenCalled
10161053

0 commit comments

Comments
 (0)