-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(experimental): support aria snapshot #9668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hi-ogawa
wants to merge
244
commits into
vitest-dev:main
Choose a base branch
from
hi-ogawa:feat-aria-snapshot
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 185 commits
Commits
Show all changes
244 commits
Select commit
Hold shift + click to select a range
5d3c2ab
feat: aria snapshot
hi-ogawa 986b451
feat: toMatchDomainInlineSnapshot
hi-ogawa 5c9458d
feat: toMatchDomainSnapshot
hi-ogawa 9e53df4
wip
hi-ogawa d965f3f
chore: design doc
hi-ogawa 4df273d
Merge branch 'main' into feat-aria-snapshot
hi-ogawa 54696d7
wip: revert slop
hi-ogawa 1a2cdb2
test: wip
hi-ogawa 0066bc0
wip: comment out more slop
hi-ogawa 099cdd3
wip: custom match
hi-ogawa 36a25a9
wip: aria
hi-ogawa 011712e
wip: aria prototype
hi-ogawa 9ab69f6
wip: aria domain
hi-ogawa 832e4e1
wip: more aria
hi-ogawa 3fccafe
docs: design
hi-ogawa e99d081
wip: docs
hi-ogawa 477e642
test/snapshots/README.md
hi-ogawa 83f9240
chore: cleanup
hi-ogawa 0a75d63
test: split
hi-ogawa 9158aad
test: gitignore
hi-ogawa dadbbe1
test: wip
hi-ogawa 4716df1
test: wip
hi-ogawa 7767628
test: wip
hi-ogawa f7e15ae
test: wip
hi-ogawa 8cd7617
feat: partial update
hi-ogawa b183e4c
test: diff
hi-ogawa 77282a9
design docs
hi-ogawa 38e0cb1
refactor: remove slop `DomainMatchResult.mismatches`
hi-ogawa 055f912
test: aria
hi-ogawa afe6d6a
design docs: inline
hi-ogawa 0e1aa40
wip: inline
hi-ogawa 2726322
test: inline e2e
hi-ogawa cc089ba
design docs: aria
hi-ogawa fc97217
feat: toMatchAriaSnapshot
hi-ogawa d481ef7
refactor: remove slop
hi-ogawa 0e41364
test: more
hi-ogawa ce20c13
test: simplify
hi-ogawa 009ec90
test: domain-aria-inline
hi-ogawa 6208a2a
wip: aria better match
hi-ogawa 259dbf2
feat: aria better match
hi-ogawa b6897de
test: rename
hi-ogawa ae5c302
test: update
hi-ogawa 62670e9
test: update
hi-ogawa d62e9fd
chore: lint
hi-ogawa b4c123d
design docs: poll + snapshot via domain model
hi-ogawa 580db2e
design docs: more on poll + snapshot
hi-ogawa 6ebeaf5
wip: poll + domain snapshot
hi-ogawa b730f3a
wip: more on poll + snapshot
hi-ogawa 3a214b9
test: more poll snapshot
hi-ogawa 2d3fad9
wip: poll snapshot
hi-ogawa b78777e
wip: poll snapshot
hi-ogawa 79b9748
wip: poll snapshot with timeout
hi-ogawa 437ff9c
test: more
hi-ogawa 700db56
chore: cleanup
hi-ogawa fea46b3
test: move code
hi-ogawa 0ad314f
test: update snapshot
hi-ogawa f348173
test: browser mode + aria
hi-ogawa eb312df
refactor: consolidate four domain snapshots
hi-ogawa 65533b4
test: wip poll + snapshot inline
hi-ogawa 2eddd71
fix: poll + domain inline snapshot
hi-ogawa a52b717
test: poll domain inline snapshot e2e
hi-ogawa 0396ce2
test: browser mode + aria
hi-ogawa ec5b402
fix: webkit curse
hi-ogawa 059b421
chore: jsdoc experimental
hi-ogawa 5d5bab4
refactor: remove slop
hi-ogawa a70ffe8
docs: aria snapshot
hi-ogawa 2fcb89f
docs: experimental domain snapshot
hi-ogawa 392b143
Merge branch 'main' into feat-aria-snapshot
hi-ogawa f3c40d3
docs: tweak
hi-ogawa 9766a9a
refactor: remove slop
hi-ogawa 7b8da57
chore: remove slop
hi-ogawa 2dbaa4f
refactor: remove slop
hi-ogawa 1bf5d5f
docs: update
hi-ogawa 4cf4112
test: more coverage
hi-ogawa 4df4fa5
fix: more aria
hi-ogawa f1b1242
test: more snapshot
hi-ogawa f7493c7
test: more aria
hi-ogawa 6fb0517
chore: remove ai docs
hi-ogawa f2eae4c
fix: better aria match
hi-ogawa 9b696b0
test: organize
hi-ogawa 7aeccb8
fix: better aria udpate
hi-ogawa dfb90e3
test: more
hi-ogawa 2027604
fix: aria psheudo attribute (link url, input placeholder)
hi-ogawa cd3fa2e
test: pseudo attribute with children
hi-ogawa 4dbfa4a
chore: cleanup
hi-ogawa a55a1dc
chore: todo
hi-ogawa e9e8082
fix: inline aria inside loop
hi-ogawa ca0abbc
refactor: consolidate SnapshotState.match/matchDomain
hi-ogawa c38d008
chore: rename
hi-ogawa 3cc7204
fix: replace Date.now with performance.now for measuring deadline
hi-ogawa 4ae35b0
chore: move code
hi-ogawa 2b47c4d
test: ws endpoint implies headless
hi-ogawa e24dbee
test: wip browser mode
hi-ogawa 027213d
test: cleanup
hi-ogawa 4ee88c7
fix: fix poll inline snapshot on firefox
hi-ogawa 5afece7
test: full browser test
hi-ogawa 1e0cc18
test: fix errorProjectTree
hi-ogawa d13a9fa
test: rolldown
hi-ogawa 66dcfa5
test: snapshot for win
hi-ogawa 1018ba9
test: more snapshot
hi-ogawa c3d48d5
test: rename
hi-ogawa 4cd6546
test: consolidate
hi-ogawa 48e9383
test: consolidate more
hi-ogawa f400313
test: more
hi-ogawa 3328d9e
test: more
hi-ogawa 7a9f42e
test: tweak
hi-ogawa 0a7fde5
test: consolidate
hi-ogawa 992e9e2
test: more
hi-ogawa bf6603d
test: more
hi-ogawa b040f37
Merge branch 'main' into feat-aria-snapshot
hi-ogawa b00490a
chore: comment
hi-ogawa 666b46b
chore: more aria plan
hi-ogawa fa99722
chore: unused
hi-ogawa 192d5aa
docs: aria.md
hi-ogawa de348ab
docs: wip
hi-ogawa 26d1db7
docs: wip
hi-ogawa d921fae
docs: polish
hi-ogawa 1b90efe
docs: wip
hi-ogawa f8414fe
docs: don't teach aria spec itself
hi-ogawa e25e29b
docs: refine aria snapshots guide
hi-ogawa df2b027
docs: domain snapshot details
hi-ogawa 1d81e77
chore: update ivya
hi-ogawa e30ee94
wip: integrate ivya aria utils
hi-ogawa 4fccea2
chore: remove slop comment
hi-ogawa 60eee34
test: test ivya aria
hi-ogawa 811069f
chore: move aria snapshot adapter to `@vitest/browser`
hi-ogawa beda188
Merge branch 'main' into feat-aria-snapshot
hi-ogawa cbe4414
Merge remote-tracking branch 'origin/feat-aria-snapshot' into feat-ar…
hi-ogawa 09fa4d4
chore: cleanup unused
hi-ogawa ccd32bd
test: update browser mode test
hi-ogawa e54928b
docs: update to new aria
hi-ogawa 919607f
refactor: simplify DomainMatchResult
hi-ogawa b932ee8
test: simplify slop
hi-ogawa d2fc250
refactor: minor slop
hi-ogawa 3cf2570
docs: wip
hi-ogawa b8422e9
test: make kv example cooler
hi-ogawa 1233118
docs: domain snapshot example
hi-ogawa c1e2a54
Merge branch 'main' into feat-aria-snapshot
hi-ogawa 094c285
test: move tests
hi-ogawa 12ed38c
test: test parse error
hi-ogawa f962ffc
fix: increase Error.stackTraceLimit for yaml parse error stack
hi-ogawa f92056d
chore(deps): update ivya
hi-ogawa f5ee886
Merge branch 'main' into feat-aria-snapshot
hi-ogawa c770fde
chore: remove yaml
hi-ogawa 23983f1
chore: lint
hi-ogawa 592ad57
chore: update ivya
hi-ogawa 35a21d4
chore: cleanup tgz
hi-ogawa 01643f0
chore: cleanup deps
hi-ogawa 6ea37b7
chore: cleanup
hi-ogawa 0de6507
fix: poll stable snapshot for initial and updated snapshot
hi-ogawa 6ee3ce5
test: test stable snapshot
hi-ogawa 19eb447
chore: todo
hi-ogawa e041f40
chore: todo
hi-ogawa 6f10f8e
fix: rework pollAssertDomain and always require stable snapshot
hi-ogawa dae9360
refactor: minor slop
hi-ogawa 525bda6
chore: comment
hi-ogawa 95de460
refactor: minor
hi-ogawa 06f1f9b
fix: poll both stable and match on existing snapshot
hi-ogawa afd2eb5
docs: document /children directive and YAML subset for aria snapshots
hi-ogawa ad3fb07
docs: rewrite browser mode retry behavior section
hi-ogawa 1b9e283
test: wip
hi-ogawa d50d9c4
test: wip
hi-ogawa 2271646
fix: fix poll timeout
hi-ogawa 7f6e218
fix: fix poll mismatch error
hi-ogawa 0a2bcf0
test: more
hi-ogawa 2176fce
test: more
hi-ogawa ff5b3e9
test: port to inline
hi-ogawa 6e9b860
docs: add experimental tags with version and sidebar entry for aria s…
hi-ogawa fbd1352
test: update
hi-ogawa 6577e07
test: firefox blip
hi-ogawa b2ee333
refactor: rename slop
hi-ogawa 5192571
fix: add assertionName to inline snapshot location validation error
hi-ogawa ee0924a
Merge branch 'main' into feat-aria-snapshot
hi-ogawa 9aeeba9
docs: fix ARIA acronym casing and anchor consistency
hi-ogawa ba27b0b
Merge branch 'main' into feat-aria-snapshot
hi-ogawa 2ad6077
docs: Aria -> ARIA
hi-ogawa 276d481
docs: Update docs/guide/snapshot.md
hi-ogawa 03b524b
docs: Ari
hi-ogawa d14f6aa
docs: Update packages/browser/src/client/tester/aria.ts
hi-ogawa 9e26248
docs: Update packages/browser/jest-dom.d.ts
hi-ogawa add1888
Merge remote-tracking branch 'origin/feat-aria-snapshot' into feat-ar…
hi-ogawa dfd000d
docs: Update docs/guide/browser/aria-snapshots.md
hi-ogawa 0041edb
docs: Update docs/guide/browser/aria-snapshots.md
hi-ogawa dca26a6
Merge remote-tracking branch 'origin/feat-aria-snapshot' into feat-ar…
hi-ogawa 67949f1
docs: tidy up jsdoc
hi-ogawa 7e9ca5c
Merge branch 'main' into feat-aria-snapshot
hi-ogawa e002f9b
refactor: add matchDomain
hi-ogawa a984079
chore: fix merge conflict
hi-ogawa 7406a75
refactor: copy assertMatchResult
hi-ogawa 61f464e
refactor: pollAssertDomain -> pollMatchDomain
hi-ogawa a2c6143
refactor: remove assertXxx
hi-ogawa 29cce4a
refactor: nit
hi-ogawa 8145a2f
refactor: nit
hi-ogawa 8de98d2
refactor: nit
hi-ogawa c72c7b1
refactor: towards custom matcher support
hi-ogawa 78abf15
chore: lint
hi-ogawa d5c1a28
Merge branch 'main' into feat-aria-snapshot
hi-ogawa 9309f1a
test: dogfood aria snapshot in packages/ui
hi-ogawa 6c7314d
test: more dogfooding
hi-ogawa 44d81a8
Merge branch 'main' into feat-aria-snapshot
hi-ogawa 9cca550
merge: resolve snapshot conflict with custom matcher support
hi-ogawa d6fa7a9
fix: remove duplicate snapshot match helper after merge
hi-ogawa d19bd78
docs: bump snapshot experimental version tags to 4.1.3
hi-ogawa ac7c69d
docs: Update docs/guide/snapshot.md
hi-ogawa 0803352
docs: more experimental
hi-ogawa af3f8d7
Merge remote-tracking branch 'origin/feat-aria-snapshot' into feat-ar…
hi-ogawa 70d8406
refactor: nit r.pass
hi-ogawa 09089df
chore: lint
hi-ogawa 441ba7d
test: packages/ui test on ci
hi-ogawa e740a5d
test: use expect.element(result.locator)
hi-ogawa 8533f7c
chore: reduce diff
hi-ogawa bb8207c
test: update
hi-ogawa e548675
chore: improve _resolveInlineStack debug error
hi-ogawa d0c22f1
fix/refactor: use __VITEST_POLL_CHAIN__ and STACK_TRACE_ERROR
hi-ogawa e6f4365
test: remove dup
hi-ogawa 0fa75d8
refactor: bye __VITEST_POLL_PROMISE__
hi-ogawa c5c43f7
refactor: simplify assertDomainSnapshot
hi-ogawa c73afc8
refactor: remove unused
hi-ogawa c6da0b6
refactor: simiplify matchDomain
hi-ogawa a50c517
refactor: nit
hi-ogawa 85ce4cf
refactor: make matchDomain tighter
hi-ogawa 1a92e97
refactor: rename matchDomain -> processDomainSnapshot
hi-ogawa 15b619d
chore: todo
hi-ogawa b359adb
test: update rolldown snapshot
hi-ogawa 02d82be
refactor: use custom matcher for domain snapshot (#5)
hi-ogawa eb358c1
Merge branch 'main' into feat-aria-snapshot
hi-ogawa e9ea61d
wip: move to Snapshots.toMatchDomain(Inline)Snapshot
hi-ogawa 4b4a0b0
docs: update to Snapshots namespace
hi-ogawa 1dc0272
test: refactor utils
hi-ogawa 6a0db71
test: update exports
hi-ogawa d64264d
chore: revert unneeded
hi-ogawa 3daea9f
test: cleanup comments
hi-ogawa 78553a7
test: update snapshot
hi-ogawa 1ff071a
Merge branch 'main' into feat-aria-snapshot
hi-ogawa a60ab07
fix: this.__vitest_assertion__ -> this.assertion
hi-ogawa 6e02739
docs: tweak
hi-ogawa 0395f71
docs: fix experimental API release markers
hi-ogawa 52dddf7
docs: not this slop
hi-ogawa f87235f
docs: correct snapshot guide version markers
hi-ogawa f4736ac
docs: clarify aria snapshot whitespace normalization
hi-ogawa cde768a
test: test multiline paragraph
hi-ogawa d550648
chore: tweak comment
hi-ogawa 2517f92
refactor: nit
hi-ogawa 1a2fecb
chore: comment
hi-ogawa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -964,6 +964,77 @@ The same as [`toMatchSnapshot`](#tomatchsnapshot), but expects the same value as | |
|
|
||
| The same as [`toMatchInlineSnapshot`](#tomatchinlinesnapshot), but expects the same value as [`toThrow`](#tothrow). | ||
|
|
||
| ## toMatchAriaSnapshot <Version type="experimental">4.1.1</Version> <Experimental /> {#tomatcharisnapshot} | ||
|
|
||
| - **Type:** `() => void` | ||
|
|
||
| Captures the accessibility tree of a DOM element and compares it against a stored snapshot. Inspired by [Playwright's ARIA snapshots](https://playwright.dev/docs/aria-snapshots). | ||
|
||
|
|
||
| The snapshot uses a YAML-like format describing the accessible roles, names, and states of the element tree. | ||
|
|
||
| ```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() | ||
| }) | ||
| ``` | ||
|
|
||
| On first run, Vitest generates a snapshot entry like: | ||
|
|
||
| ``` | ||
| - navigation "Actions": | ||
| - button: Save | ||
| - button: Cancel | ||
| ``` | ||
|
|
||
| See the [ARIA Snapshots guide](/guide/browser/aria-snapshots) for more details. | ||
|
|
||
| ## toMatchAriaInlineSnapshot <Version type="experimental">4.1.1</Version> <Experimental /> {#tomatchariainlinesnapshot} | ||
hi-ogawa marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - **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 | ||
| `) | ||
| }) | ||
| ``` | ||
|
|
||
| ## toMatchDomainSnapshot <Version type="experimental">4.1.1</Version> <Experimental /> {#tomatchdomainsnapshot} | ||
hi-ogawa marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - **Type:** `(domain: string, hint?: string) => void` | ||
|
|
||
| Matches a value against a stored snapshot using a registered [domain snapshot adapter](/guide/snapshot#custom-snapshot-domain). The `domain` argument is the adapter's `name`. | ||
|
|
||
| ```ts | ||
| expect(value).toMatchDomainSnapshot('my-domain') | ||
| ``` | ||
|
|
||
| ## toMatchDomainInlineSnapshot <Version type="experimental">4.1.1</Version> <Experimental /> {#tomatchdomaininlinesnapshot} | ||
hi-ogawa marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - **Type:** `(snapshot: string, domain: string, hint?: string) => void` | ||
|
|
||
| Same as [`toMatchDomainSnapshot`](#tomatchdomainsnapshot), but stores the snapshot inline in the test file. | ||
|
|
||
| ```ts | ||
| expect(value).toMatchDomainInlineSnapshot(`...`, `my-domain`) | ||
| ``` | ||
|
|
||
| ## toHaveBeenCalled | ||
|
|
||
| - **Type:** `() => Awaitable<void>` | ||
|
|
@@ -2116,6 +2187,19 @@ If you are adding custom serializers, you should call this method inside [`setup | |
| If you previously used Vue CLI with Jest, you might want to install [jest-serializer-vue](https://npmx.dev/package/jest-serializer-vue). Otherwise, your snapshots will be wrapped in a string, which cases `"` to be escaped. | ||
| ::: | ||
|
|
||
| ## expect.addSnapshotDomain <Version type="experimental">4.1.1</Version> <Experimental /> {#expect-addsnapshotdomain} | ||
hi-ogawa marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - **Type:** `(adapter: DomainSnapshotAdapter) => void` | ||
|
|
||
| Registers a [domain snapshot adapter](/guide/snapshot#custom-snapshot-domain) for use with `toMatchDomainSnapshot` and `toMatchDomainInlineSnapshot`. Call this in [`setupFiles`](/config/setupfiles). | ||
|
|
||
| ```ts | ||
| import { expect } from 'vitest' | ||
| import { kvAdapter } from './kv-adapter' | ||
|
|
||
| expect.addSnapshotDomain(kvAdapter) | ||
| ``` | ||
hi-ogawa marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## expect.extend | ||
|
|
||
| - **Type:** `(matchers: MatchersObject) => void` | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.