Skip to content
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
34 changes: 18 additions & 16 deletions docs/dom-testing-library/api-configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,15 @@ second argument. If you're using testing-library in a browser you almost always
want to set this to `true`. Only very old browser don't support this property
(such as IE 8 and earlier). However, `jsdom` does not support the second
argument currently. This includes versions of `jsdom` prior to `16.4.0` and any
version that logs a `not implemented` warning when calling `getComputedStyle`
version that logs a `not implemented` warning when calling
[`getComputedStyle`](https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle)
with a second argument e.g.
`window.getComputedStyle(document.createElement('div'), '::after')`. Defaults to
`false`

### `defaultHidden`

The default value for the `hidden` option used by
The default value for the [`hidden` option](queries/byrole#hidden) used by
[`getByRole`](queries/byrole.mdx). Defaults to `false`.

### `defaultIgnore`
Expand All @@ -110,12 +111,12 @@ Defaults to `script, style`.

### `showOriginalStackTrace`

By default, `waitFor` will ensure that the stack trace for errors thrown by
Testing Library is cleaned up and shortened so it's easier for you to identify
the part of your code that resulted in the error (async stack traces are hard to
debug). If you want to disable this, then set`showOriginalStackTrace` to
`false`. You can also disable this for a specific call in the options you pass
to `waitFor`.
By default, [`waitFor`](api-async#waitfor) will ensure that the stack trace for
errors thrown by Testing Library is cleaned up and shortened so it's easier for
you to identify the part of your code that resulted in the error (async stack
traces are hard to debug). If you want to disable this, then
set`showOriginalStackTrace` to `false`. You can also disable this for a specific
call in the options you pass to `waitFor`.

### `throwSuggestions` (experimental)

Expand All @@ -132,8 +133,8 @@ screen.getByTestId('foo', {suggest: false}) // will not throw a suggestion

:::note

When this option is enabled, it may provide suggestions that lack an
intuitive implementation. Typically this happens for
When this option is enabled, it may provide suggestions that lack an intuitive
implementation. Typically this happens for
[roles which cannot 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:
Expand All @@ -143,12 +144,13 @@ TestingLibraryElementError: A better query is available, try this:
getByRole('paragraph')
```

However, there is no direct way to query paragraphs using the config object parameter, such as in
`getByRole('paragraph', { name: 'Hello World' })`.
However, there is no direct way to query paragraphs using the config object
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, as shown in the example below.
More information can be found in the [GitHub issue](https://github.com/testing-library/dom-testing-library/issues/1306)
element's structure, as shown in the example below. More information can be
found in the
[GitHub issue](https://github.com/testing-library/dom-testing-library/issues/1306)

```js
getByRole('paragraph', {
Expand All @@ -171,5 +173,5 @@ message and container object as arguments.

### `asyncUtilTimeout`

The global timeout value in milliseconds used by `waitFor` utilities. Defaults
to 1000ms.
The global timeout value in milliseconds used by [`waitFor`](api-async#waitfor)
utilities. Defaults to 1000ms.
6 changes: 3 additions & 3 deletions docs/dom-testing-library/api-debugging.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ you'd like a solution that works for both, see
## `prettyDOM`

Built on top of
[`pretty-format`](https://github.com/facebook/jest/tree/master/packages/pretty-format),
[`pretty-format`](https://github.com/jestjs/jest/tree/main/packages/pretty-format),
this helper function can be used to print out readable representation of the DOM
tree of a node. This can be helpful for instance when debugging tests.

Expand All @@ -79,7 +79,7 @@ It receives the root node to print out, an optional extra parameter to limit the
size of the resulting string, for cases when it becomes too large. It has a last
parameter which allows you to configure your formatting. In addition to the
options listed you can also pass the
[options](https://github.com/facebook/jest/tree/master/packages/pretty-format#usage-with-options)
[options](https://github.com/jestjs/jest/tree/main/packages/pretty-format#usage-with-options)
of `pretty-format`.

By default, `<style />`, `<script />` and comment nodes are ignored. You can
Expand All @@ -101,7 +101,7 @@ console.log(prettyDOM(div))
```

This function is what also powers
[the automatic debugging output described above](#debugging).
[the automatic debugging output described above](#automatic-logging).

## `screen.debug()`

Expand Down