Skip to content

Commit cb569a2

Browse files
author
EBAM006
committed
doc: add documentation for the new naming
1 parent 891b293 commit cb569a2

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

website/docs/API.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ title: API
5050
- [Configuration](#configuration)
5151
- [`configure`](#configure)
5252
- [`asyncUtilTimeout` option](#asyncutiltimeout-option)
53+
- [`defaultIncludeHidden` option](#defaultincludehidden-option)
5354
- [`defaultHidden` option](#defaulthidden-option)
5455
- [`defaultDebugOptions` option](#defaultdebugoptions-option)
5556
- [`resetToDefaults()`](#resettodefaults)
@@ -791,9 +792,13 @@ function configure(options: Partial<Config>) {}
791792

792793
Default timeout, in ms, for async helper functions (`waitFor`, `waitForElementToBeRemoved`) and `findBy*` queries. Defaults to 1000 ms.
793794

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+
794799
#### `defaultHidden` option
795800

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`.
797802

798803
#### `defaultDebugOptions` option
799804

website/docs/Queries.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ title: Queries
2727
- [Default state for: `checked` and `expanded` keys](#default-state-for-checked-and-expanded-keys)
2828
- [`ByA11Value`, `ByAccessibilityValue`](#bya11value-byaccessibilityvalue)
2929
- [Common options](#common-options)
30+
- [`includeHidden` option](#includehidden-option)
3031
- [`hidden` option](#hidden-option)
3132
- [TextMatch](#textmatch)
3233
- [Examples](#examples)
@@ -376,9 +377,9 @@ const element = screen.getByA11yValue({ min: 40 });
376377

377378
## Common options
378379

379-
### `hidden` option
380+
### `includeHidden` option
380381

381-
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.
382383

383384
You can configure the default value with the [`configure` function](API.md#configure).
384385

@@ -389,18 +390,22 @@ An element is considered to be hidden from accessibility based on [`isHiddenFrom
389390
```tsx
390391
render(<Text style={{ display: 'none' }}>I am hidden from accessibility</Text>);
391392

392-
// Ignore hidden elements
393+
// Include hidden elements
393394
expect(
394-
screen.queryByText('I am hidden from accessibility', { hidden: false })
395+
screen.queryByText('I am hidden from accessibility', { includeHidden: false })
395396
).toBeFalsy();
396397

397398
// 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
399400
expect(
400-
screen.getByText('I am hidden from accessibility', { hidden: true })
401+
screen.getByText('I am hidden from accessibility', { includeHidden: true })
401402
).toBeTruthy();
402403
```
403404

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`.
408+
404409
## TextMatch
405410

406411
```ts

0 commit comments

Comments
 (0)