Skip to content

Commit 6b02710

Browse files
authored
docs: Add new a11y matchers and prepare for 2.x (#263)
* docs: Add new a11y matchers and prepare for 2.x * Update docs
1 parent 6d31da2 commit 6b02710

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

docs/Queries.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,34 @@ const { getByA11yRole } = render(<MyComponent />);
148148
const element = getByA11yRole('button');
149149
```
150150

151+
### `ByA11yState`, `ByAccessibilityState`
152+
153+
> getByA11yState, getAllByA11yState, queryByA11yState, queryAllByA11yState
154+
> getByAccessibilityState, getAllByAccessibilityState, queryByAccessibilityState, queryAllByAccessibilityState
155+
156+
Returns a `ReactTestInstance` with matching `accessibilityState` prop.
157+
158+
```jsx
159+
import { render } from 'react-native-testing-library';
160+
161+
const { getByA11yState } = render(<Component />);
162+
const element = getByA11yState({ disabled: true });
163+
```
164+
165+
### `ByA11Value`, `ByAccessibilityValue`
166+
167+
> getByA11yValue, getAllByA11yValue, queryByA11yValue, queryAllByA11yValue
168+
> getByAccessibilityValue, getAllByAccessibilityValue, queryByAccessibilityValue, queryAllByAccessibilityValue
169+
170+
Returns a `ReactTestInstance` with matching `accessibilityValue` prop.
171+
172+
```jsx
173+
import { render } from 'react-native-testing-library';
174+
175+
const { getByA11yValue } = render(<Component />);
176+
const element = getByA11yValue({ min: 40 });
177+
```
178+
151179
## Unit testing helpers
152180

153181
> Use sparingly and responsibly, escape hatches here
@@ -159,20 +187,23 @@ const element = getByA11yRole('button');
159187

160188
The interface is the same as for other queries, but we won't provide full names so that they're harder to find by search engines.
161189

162-
### `ByType`
190+
### `UNSAFE_ByType`, `ByType`
163191

164192
> Note: added in v1.4
165193
194+
> This method has been **deprecated** and has been prepended with `UNSAFE_` prefix. In react-native-testing-library 2.x only the prefixed version will work.
195+
166196
A method returning a `ReactTestInstance` with matching a React component type. Throws when no matches.
167197

168-
### `ByProps`
198+
### `UNSAFE_ByProps`, `ByProps`
199+
200+
> This method has been **deprecated** and has been prepended with `UNSAFE_` prefix. In react-native-testing-library 2.x only the prefixed version will work.
169201
170202
A method returning a `ReactTestInstance` with matching props object
171203

172204
### `ByName`
173205

174206
> This method has been **deprecated** because using it results in fragile tests that may break between minor React Native versions. **DON'T USE IT**. It will be removed in next major release (v2.0). Use [`getByTestId`](#bytestid) instead. It's listed here only for back-compat purposes for early adopters of the library
175-
176207
A method returning a `ReactTestInstance` with matching a React component type. Throws when no matches.
177208

178209
</details>

0 commit comments

Comments
 (0)