Idea: expect(getAccessibilityTree(page)).toMatchInlineSnapshot()
See original GitHub issueIt would be cool to write snapshot tests against the accessibility tree, something like:
test(
'asdf',
withBrowser(async ({ utils }) => {
// ...
expect(await getAccessibilityTree(pageOrNode)).toMatchInlineSnapshot(`
heading "accessible name"
link "accessible name"
text "asdf"
text "asdf"
paragraph "some text in a paragraph"
text "some text in a paragraph"
`)
}),
)
The tree would be as similar as possible to the accessibility tree shown in Chrome/Firefox
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Snapshot Testing - Jest
Snapshot tests are a very useful tool whenever you want to make sure your UI does not change unexpectedly.
Read more >Accessibility Tree Snapshots in Pleasantest - Cloud Four
At various points throughout your Pleasantest test, you can write: expect(await getAccessibilityTree(element)).toMatchInlineSnapshot();.
Read more >Snapshot | Guide - Vitest
Learn Snapshot by video from Vue School. Snapshot tests are a very useful tool whenever you want to make sure the output of...
Read more >cloudfour/pleasantest: Write real-browser tests with ... - GitHub
You can use Testing Library queries to find elements on the page. ... option is to use the getAccessibilityTree function to create snapshots...
Read more >How To Write Snapshot Tests For React Components With Jest
When writing snapshot tests for a React component, you first need to have code in a working state. Then, generate a snapshot of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@calebeby I like your idea!
Even at the basic level of “list all headings” or “list all articles” or “list all links” would be good. It’s another lens to help us see when we could enhance the experience. For example, if all articles on the page were listed as “article, article, article” then it would give us insight to consider making that experience better. 👍
Closing this as getAccessibilityTree has been implemented/published. There are some ideas in this issue that are not implemented and might be worth implementing down the road. We can come back to them as we try out getAccessibilityTree on real work and find the pain points.