diff --git a/docs/dom-testing-library/api-queries.md b/docs/dom-testing-library/api-queries.md index aeae82341..1843cd285 100644 --- a/docs/dom-testing-library/api-queries.md +++ b/docs/dom-testing-library/api-queries.md @@ -625,6 +625,7 @@ getByRole( checked?: boolean, pressed?: boolean, queryFallbacks?: boolean, + level?: number, }): HTMLElement ``` @@ -635,7 +636,7 @@ attribute. Here you can see [a table of HTML elements with their default and desired roles](https://www.w3.org/TR/html-aria/#docconformance). Please note that setting a `role` and/or `aria-*` attribute that matches the -implicit ARIA semantics is unnecessary and is **not recomended** as these +implicit ARIA semantics is unnecessary and is **not recommended** as these properties are already set by the browser, and we must not use the `role` and `aria-*` attributes in a manner that conflicts with the semantics described. For example, a `button` element can't have the `role` attribute of `heading`, @@ -787,6 +788,8 @@ cy.findByRole('dialog').should('exist') +#### `queryFallbacks` + By default, it's assumed that the first role of each element is supported, so only the first role can be queried. If you need to query an element by any of its fallback roles instead, you can use `queryFallbacks: true`. @@ -803,6 +806,53 @@ roles and therefore match the same element. > roles get introduced and you want to start supporting those as well as older > environments that don't understand that role (yet). +#### `level` + +An element with the `heading` role can be queried by any heading level +`getByRole('heading')` or by a specific heading level using the `level` option +`getByRole('heading', { level: 2 })`. + +The `level` option queries the element(s) with the `heading` role matching the +indicated level determined by the semantic HTML heading elements `