question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Idea: expect(getAccessibilityTree(page)).toMatchInlineSnapshot()

See original GitHub issue

It 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:closed
  • Created 2 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
gerardo-rodriguezcommented, Nov 19, 2021

@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. 👍

0reactions
calebebycommented, Dec 22, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found