From 5c5d87d3ded44d79e7426700f94fd2b743dc371f Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Wed, 6 May 2020 21:57:14 +0200 Subject: [PATCH] docs(ByRole): Add { selected: boolean } option --- docs/dom-testing-library/api-queries.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/docs/dom-testing-library/api-queries.md b/docs/dom-testing-library/api-queries.md index dbd00e469..fc0bb08f8 100644 --- a/docs/dom-testing-library/api-queries.md +++ b/docs/dom-testing-library/api-queries.md @@ -585,6 +585,7 @@ getByRole( hidden?: boolean = true, name?: TextMatch, normalizer?: NormalizerFn, + selected?: boolean, }): HTMLElement ``` @@ -637,7 +638,27 @@ case. For example in assertions about the `Open dialog`-button you would need to use `getAllByRole('button', { hidden: true })`. -The default value can [be configured](api-configuration#configuration). +The default value for `hidden` can [be configured](api-configuration#configuration). + +Certain roles can have a selected state. You can filter the +returned elements that by their selected state +by setting `selected: true` or `selected: false`. + +For example in + +```html + +
+ + + +
+ +``` + +you can get the "Native"-tab by calling `getByRole('tab', { selected: true })`. +To learn more about the selected state and which elements can +have this state see [ARIA `aria-selected`](https://www.w3.org/TR/wai-aria-1.2/#aria-selected). ```html
...