You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Another option is to use the [`getAccessibilityTree`](#getaccessibilitytreeelement-options-accessibilitytreeoptions--promiseaccessibilitytreesnapshot) function to create snapshots of the expected accessibility tree.
226
+
Another option is to use the [`getAccessibilityTree`](#getaccessibilitytreeelement-elementhandle--page-options-accessibilitytreeoptions--promiseaccessibilitytreesnapshot) function to create snapshots of the expected accessibility tree.
The `getAccessibilityTree` function is a top-level import from `pleasantest`. It is intended to be used with [Jest Snapshots](https://jestjs.io/docs/snapshot-testing#snapshot-testing-with-jest) to ensure that any changes to the accessibility tree of your component or application are intended and correct.
743
743
@@ -753,12 +753,10 @@ test(
753
753
withBrowser(async ({ page }) => {
754
754
// ... Load your content here (see Loading Content)
// You could alternatively choose a more specific element for which to print the accessibility tree
758
-
759
756
awaitexpect(
760
757
// Note the use of `await`; getAccessibilityTree returns a Promise
761
-
awaitgetAccessibilityTree(bodyElement),
758
+
// Also, you could pass a specific element instead of the page
759
+
awaitgetAccessibilityTree(page),
762
760
).toMatchInlineSnapshot();
763
761
}),
764
762
);
@@ -776,6 +774,8 @@ list
776
774
text "something else"
777
775
```
778
776
777
+
The first parameter must be either an `ElementHandle` or the `Page` object. If an `ElementHandle` is passed, the accessibility tree will contain only descendants of that element. If the `Page` object is passed, the accessibility tree will be of the entire document.
778
+
779
779
The second parameter (optional) is `AccessibilityTreeOptions`, and it allows you to configure what is shown in the output.
780
780
781
781
`AccessibilityTreeOptions` (all properties are optional):
0 commit comments