Skip to content

Commit ce1ca63

Browse files
authored
update api-configuration.mdx (#730)
Small changes to make document easier to read
1 parent 5ccb283 commit ce1ca63

File tree

1 file changed

+51
-45
lines changed

1 file changed

+51
-45
lines changed

docs/dom-testing-library/api-configuration.mdx

Lines changed: 51 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title: Configuration
66
import Tabs from '@theme/Tabs'
77
import TabItem from '@theme/TabItem'
88

9-
## Configuration
9+
## Introduction
1010

1111
The library can be configured via the `configure` function, which accepts:
1212

@@ -16,50 +16,7 @@ The library can be configured via the `configure` function, which accepts:
1616
return a plain JS object which will be merged as above, e.g.
1717
`configure(existingConfig => ({something: [...existingConfig.something, 'extra value for the something array']}))`
1818

19-
Configuration options:
20-
21-
`computedStyleSupportsPseudoElements`: Set to `true` if
22-
`window.getComputedStyle` supports pseudo-elements i.e. a second argument. If
23-
you're using testing-library in a browser you almost always want to set this to
24-
`true`. Only very old browser don't support this property (such as IE 8 and
25-
earlier). However, `jsdom` does not support the second argument currently. This
26-
includes versions of `jsdom` prior to `16.4.0` and any version that logs a
27-
`not implemented` warning when calling `getComputedStyle` with a second argument
28-
e.g. `window.getComputedStyle(document.createElement('div'), '::after')`.
29-
Defaults to `false`
30-
31-
`defaultHidden`: The default value for the `hidden` option used by
32-
[`getByRole`](api-queries.mdx#byrole). Defaults to `false`.
33-
34-
`showOriginalStackTrace`: By default, `waitFor` will ensure that the stack trace
35-
for errors thrown by Testing Library is cleaned up and shortened so it's easier
36-
for you to identify the part of your code that resulted in the error (async
37-
stack traces are hard to debug). If you want to disable this, then
38-
set`showOriginalStackTrace` to `false`. You can also disable this for a specific
39-
call in the options you pass to `waitFor`.
40-
41-
`throwSuggestions`: (experimental) When enabled, if
42-
[better queries](https://testing-library.com/docs/guide-which-query) are
43-
available the test will fail and provide a suggested query to use instead.
44-
Default to `false`.
45-
46-
To disable a suggestion for a single query just add `{suggest:false}` as an
47-
option.
48-
49-
```js
50-
screen.getByTestId('foo', { suggest: false }) // will not throw a suggestion
51-
```
52-
53-
`testIdAttribute`: The attribute used by
54-
[`getByTestId`](api-queries.mdx#bytestid) and related queries. Defaults to
55-
`data-testid`.
56-
57-
`getElementError`: A function that returns the error used when
58-
[`getBy*`](api-queries.mdx#getby) or [`getAllBy*`](api-queries.mdx#getallby)
59-
fail. Takes the error message and container object as arguments.
60-
61-
`asyncUtilTimeout`: The global timeout value in milliseconds used by `waitFor`
62-
utilities. Defaults to 1000ms.
19+
## Setup
6320

6421
<Tabs defaultValue="native" values={[ { label: 'Native', value: 'native', }, {
6522
label: 'React', value: 'react', }, { label: 'Cypress', value: 'cypress', }, ] }>
@@ -100,3 +57,52 @@ configure({ testIdAttribute: 'data-my-test-id' })
10057

10158
</TabItem>
10259
</Tabs>
60+
61+
## Configuration options:
62+
63+
### `computedStyleSupportsPseudoElements`
64+
Set to `true` if `window.getComputedStyle` supports pseudo-elements i.e. a second argument. If
65+
you're using testing-library in a browser you almost always want to set this to
66+
`true`. Only very old browser don't support this property (such as IE 8 and
67+
earlier). However, `jsdom` does not support the second argument currently. This
68+
includes versions of `jsdom` prior to `16.4.0` and any version that logs a
69+
`not implemented` warning when calling `getComputedStyle` with a second argument
70+
e.g. `window.getComputedStyle(document.createElement('div'), '::after')`.
71+
Defaults to `false`
72+
73+
### `defaultHidden`
74+
The default value for the `hidden` option used by
75+
[`getByRole`](api-queries.mdx#byrole). Defaults to `false`.
76+
77+
### showOriginalStackTrace`
78+
By default, `waitFor` will ensure that the stack trace
79+
for errors thrown by Testing Library is cleaned up and shortened so it's easier
80+
for you to identify the part of your code that resulted in the error (async
81+
stack traces are hard to debug). If you want to disable this, then
82+
set`showOriginalStackTrace` to `false`. You can also disable this for a specific
83+
call in the options you pass to `waitFor`.
84+
85+
### `throwSuggestions`(experimental)
86+
When enabled, if [better queries](https://testing-library.com/docs/guide-which-query) are
87+
available the test will fail and provide a suggested query to use instead.
88+
Default to `false`.
89+
90+
To disable a suggestion for a single query just add `{suggest:false}` as an
91+
option.
92+
93+
```js
94+
screen.getByTestId('foo', { suggest: false }) // will not throw a suggestion
95+
```
96+
97+
### `testIdAttribute`
98+
The attribute used by [`getByTestId`](api-queries.mdx#bytestid) and related queries. Defaults to
99+
`data-testid`.
100+
101+
### `getElementError`
102+
A function that returns the error used when
103+
[`getBy*`](api-queries.mdx#getby) or [`getAllBy*`](api-queries.mdx#getallby)
104+
fail. Takes the error message and container object as arguments.
105+
106+
### `asyncUtilTimeout`
107+
The global timeout value in milliseconds used by `waitFor`
108+
utilities. Defaults to 1000ms.

0 commit comments

Comments
 (0)