Skip to content

Commit 25ec3e4

Browse files
eps1lonKent C. Dodds
authored andcommitted
Document default aria roles consideration (#173)
1 parent ba1a687 commit 25ec3e4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

docs/dom-testing-library/api-queries.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,15 +530,18 @@ cy.getByDisplayValue('Alaska').should('exist')
530530
```typescript
531531
getByRole(
532532
container: HTMLElement,
533-
text: TextMatch,
533+
role: TextMatch,
534534
options?: {
535535
exact?: boolean = true,
536536
normalizer?: NormalizerFn,
537537
}): HTMLElement
538538
```
539539

540-
A shortcut to `` container.querySelector(`[role="${yourRole}"]`) `` (and it also
541-
accepts a [`TextMatch`](#textmatch)).
540+
Queries for elements with the given role (and it also
541+
accepts a [`TextMatch`](#textmatch)). Default roles are taken
542+
into consideration e.g. `<button />` has the `button` role without
543+
explicitly setting the `role` attribute. The [W3C HTML recommendation](https://www.w3.org/TR/html5/index.html#contents)
544+
lists all HTML elements with their default aria roles.
542545

543546
```html
544547
<div role="dialog">...</div>

0 commit comments

Comments
 (0)