Skip to content
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

docs: add note for throwSuggestions issue #1306 #1425

Merged
30 changes: 29 additions & 1 deletion docs/dom-testing-library/api-configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,34 @@ option.
screen.getByTestId('foo', {suggest: false}) // will not throw a suggestion
```

> **Note**
enmanuelduran marked this conversation as resolved.
Show resolved Hide resolved
>
> When this option is enabled, the library may provide suggestions that lack an
> intuitive implementation, this typically occurs for
> [roles which can not be named](https://w3c.github.io/aria/#namefromprohibited),
> most notably paragraphs. For instance, if you attempt to use
> [`getByText`](queries/bytext.mdx), you may encounter the following error:
>
> ```
> TestingLibraryElementError: A better query is available, try this:
> getByRole('paragraph')
> ```
>
> However, there is no direct way to query paragraphs using an object as the
> second parameter, such as in
> `getByRole('paragraph', { name: 'Hello World' })`.
>
> To address this issue, you can leverage a custom function to validate the
> element's structure and suppress the error, see
> [#1306](https://github.com/testing-library/dom-testing-library/issues/1306)
> and the example below:
>
> ```js
> getByRole('paragraph', {
> name: (_, element) => element.textContent === 'Hello world',
> })
> ```

### `testIdAttribute`

The attribute used by [`getByTestId`](queries/bytestid.mdx) and related queries.
Expand All @@ -144,4 +172,4 @@ message and container object as arguments.
### `asyncUtilTimeout`

The global timeout value in milliseconds used by `waitFor` utilities. Defaults
to 1000ms.
to 1000ms.