You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -791,9 +792,13 @@ function configure(options: Partial<Config>) {}
791
792
792
793
Default timeout, in ms, for async helper functions (`waitFor`, `waitForElementToBeRemoved`) and `findBy*` queries. Defaults to 1000 ms.
793
794
795
+
#### `defaultIncludeHidden` option
796
+
797
+
Default [includeHidden](Queries.md#includehidden-option) query option for all queries. This default option will be overridden by the one you specify directly when using your query.
798
+
794
799
#### `defaultHidden` option
795
800
796
-
Default [hidden](Queries.md#hidden-option) query option for all queries. This default option will be overridden by the one you specify directly when using your query.
801
+
This is just an alias to the `defaultIncludeHidden` option. It only exists to match react-testing-library naming used in the [configuration options](https://testing-library.com/docs/dom-testing-library/api-configuration/#defaulthidden). Prefer the use of `defaultIncludeHidden` if possible as `defaultIncludeHidden: true` is clearer than `defaultHidden: true`.
All queries have the `hidden` option which enables them to respect accessibility props on components when it is set to `false`. If you set `hidden` to `true`, elements that are normally excluded from the accessibility tree are considered for the query as well. Currently `hidden` option is set `true` by default, which means that elements hidden from accessibility will be included by default. However, we plan to change the default value to `hidden: false` in the next major release.
382
+
All queries have the `includeHidden` option which enables them to respect accessibility props on components when it is set to `false`. If you set `includeHidden` to `true`, elements that are normally excluded from the accessibility tree are considered for the query as well. Currently `includeHidden` option is set `true` by default, which means that elements includeHidden from accessibility will be included by default. However, we plan to change the default value to `includeHidden: false` in the next major release.
382
383
383
384
You can configure the default value with the [`configure` function](API.md#configure).
384
385
@@ -389,18 +390,22 @@ An element is considered to be hidden from accessibility based on [`isHiddenFrom
389
390
```tsx
390
391
render(<Textstyle={{ display: 'none' }}>I am hidden from accessibility</Text>);
391
392
392
-
//Ignore hidden elements
393
+
//Include hidden elements
393
394
expect(
394
-
screen.queryByText('I am hidden from accessibility', { hidden: false })
395
+
screen.queryByText('I am hidden from accessibility', { includeHidden: false })
395
396
).toBeFalsy();
396
397
397
398
// Match hidden elements
398
-
expect(screen.getByText('I am hidden from accessibility')).toBeTruthy(); // Defaults to hidden: true for now
399
+
expect(screen.getByText('I am hidden from accessibility')).toBeTruthy(); // Defaults to includeHidden: true for now
399
400
expect(
400
-
screen.getByText('I am hidden from accessibility', { hidden: true })
401
+
screen.getByText('I am hidden from accessibility', { includeHidden: true })
401
402
).toBeTruthy();
402
403
```
403
404
405
+
### `hidden` option
406
+
407
+
This is just an alias to the `includeHidden` option. It only exists to match react-testing-library naming used in [byRole](https://testing-library.com/docs/queries/byrole/#hidden). Prefer the use of `includeHidden` if possible as `includeHidden: true` is clearer than `hidden: true`.
0 commit comments