Skip to content

docs: explain suggest in byRole #1220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/dom-testing-library/api-configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ to `waitFor`.

### `throwSuggestions` (experimental)

When enabled, if [better queries](queries/about.mdx#priority) are available the
test will fail and provide a suggested query to use instead. Default to `false`.
When enabled, if [better queries](queries/about.mdx#priority) are available, the
test will fail and provide a suggested query to use instead. Defaults to
`false`.

To disable a suggestion for a single query just add `{suggest:false}` as an
option.
Expand Down
8 changes: 8 additions & 0 deletions docs/queries/byrole.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ getByRole(
selected?: boolean,
checked?: boolean,
pressed?: boolean,
suggest?: boolean,
current?: boolean | string,
expanded?: boolean,
queryFallbacks?: boolean,
Expand Down Expand Up @@ -183,6 +184,13 @@ you can get the "👍" button by calling `getByRole('button', { pressed: true })
To learn more about the pressed state see
[ARIA `aria-pressed`](https://www.w3.org/TR/wai-aria-1.2/#aria-pressed).

### `suggest`

You can disable the ability to
[throw suggestions](../dom-testing-library/api-configuration#throwsuggestions-experimental)
for a specific query by setting this value to `false`.
Setting this value to `true` will throw suggestions for the specific query.

### `expanded`

You can filter the returned elements by their expanded state by setting
Expand Down