@@ -78,22 +78,22 @@ See [TextMatch](#textmatch) for documentation on what can be passed to a query.
78
78
79
79
## Queries
80
80
81
- ### ` ByA11yHint `
81
+ ### ` ByHintText `
82
82
83
- > getByA11yHint, queryByA11yHint, getAllByA11yHint, queryAllByA11yHint, findByA11yHint ,
84
- > findAllByA11yHint
83
+ > getByHintText, queryByHintText, getAllByHintText, queryAllByHintText, findByHintText ,
84
+ > findAllByHintText
85
85
86
86
``` typescript
87
- getByA11yHint (
88
- container : ReactTestRendererInstance ,
87
+ getByHintText (
88
+ testRenderer : ReactTestRendererInstance ,
89
89
match : TextMatch ,
90
90
options ?: {
91
91
exact?: boolean = true ,
92
92
trim?: boolean = true ,
93
93
collapseWhitespace?: boolean = true ,
94
- filter ?: FilterFn ,
94
+ selector ?: SelectorFn ,
95
95
normalizer?: NormalizerFn ,
96
- }): FiberRoot
96
+ }): NativeTestInstance
97
97
```
98
98
99
99
This will search for all elements with an ` accessibilityHint ` prop and find one that matches the
@@ -102,27 +102,27 @@ given [`TextMatch`](#textmatch).
102
102
``` js
103
103
import { render } from ' react-testing-library' ;
104
104
105
- const { getByA11yHint } = render (< View accessibilityHint= " summary" / > );
105
+ const { getByHintText } = render (< View accessibilityHint= " summary" / > );
106
106
107
- getByA11yHint (' summary' ); // returns the View node
107
+ getByHintText (' summary' ); // returns the View node
108
108
```
109
109
110
- ### ` ByA11yLabel `
110
+ ### ` ByLabelText `
111
111
112
- > getByA11yLabel , queryByLabelText, getAllByLabelText, queryAllByLabelText findByLabelText,
112
+ > getByLabelText , queryByLabelText, getAllByLabelText, queryAllByLabelText findByLabelText,
113
113
> findAllByLabelText
114
114
115
115
``` typescript
116
- getByA11yLabel (
117
- container : ReactTestRendererInstance ,
116
+ getByLabelText (
117
+ testRenderer : ReactTestRendererInstance ,
118
118
match : TextMatch ,
119
119
options ?: {
120
120
exact?: boolean = true ,
121
121
trim?: boolean = true ,
122
122
collapseWhitespace?: boolean = true ,
123
- filter ?: FilterFn ,
123
+ selector ?: SelectorFn ,
124
124
normalizer?: NormalizerFn ,
125
- }): FiberRoot
125
+ }): NativeTestInstance
126
126
```
127
127
128
128
This will search for all elements with an ` accessibilityLabel ` prop and find one that matches the
@@ -142,27 +142,22 @@ function Login({ onPress }) {
142
142
143
143
import { render } from ' native-testing-library' ;
144
144
145
- const { getByA11yLabel } = render (< Login onPress= {jest .fn ()} / > );
145
+ const { getByLabelText } = render (< Login onPress= {jest .fn ()} / > );
146
146
147
- getByA11yLabel (' username' ); // returns the TextInput node
147
+ getByLabelText (' username' ); // returns the TextInput node
148
148
```
149
149
150
- ### ` ByA11yRole `
150
+ ### ` ByRole `
151
151
152
- > getByA11yRole, queryByA11yRole, getAllByA11yRole, queryAllByA11yRole, findByA11yRole,
153
- > findAllByA11yRole
152
+ > getByRole, queryByRole, getAllByRole, queryAllByRole, findByRole, findAllByRole
154
153
155
154
``` typescript
156
- getByA11yRole (
157
- container : ReactTestRendererInstance ,
155
+ getByRole (
156
+ testRenderer : ReactTestRendererInstance ,
158
157
match : TextMatch ,
159
158
options ?: {
160
- exact?: boolean = true ,
161
- trim?: boolean = true ,
162
- collapseWhitespace?: boolean = true ,
163
- filter?: FilterFn ,
164
- normalizer?: NormalizerFn ,
165
- }): FiberRoot
159
+ selector?: SelectorFn ,
160
+ }): NativeTestInstance
166
161
```
167
162
168
163
This will search for all elements with an ` accessibilityRole ` prop and find one that matches the
@@ -171,73 +166,30 @@ given [`TextMatch`](#textmatch).
171
166
``` js
172
167
import { render } from ' react-testing-library' ;
173
168
174
- const { getByA11yRole } = render (< View accessibilityRole= " summary" / > );
175
-
176
- getByA11yRole (' summary' ); // returns the View node
177
- ```
178
-
179
- ### ` ByA11yStates `
180
-
181
- > getByA11yStates, queryByA11yStates, getAllByA11yStates, queryAllByA11yStates, findByA11yStates,
182
- > findAllByA11yStates
183
-
184
- ``` typescript
185
- getByA11yStates (
186
- container : ReactTestRendererInstance ,
187
- match : Array < string >
188
- ): FiberRoot
189
- ```
190
-
191
- This will search for all elements with an ` accessibilityStates ` prop and find one that matches the
192
- given ` Array ` .
193
-
194
- ``` js
195
- import { render } from ' react-testing-library' ;
196
-
197
- const { getByA11yStates } = render (< View accessibilityStates= {[' disabled' ]} / > );
198
-
199
- getByA11yStates ([' disabled' ]); // returns the View node
200
- ```
201
-
202
- ### ` ByA11yTraits `
203
-
204
- > getByA11yTraits, queryByA11yTraits, getAllByA11yTraits, queryAllByA11yTraits, findByA11yTraits,
205
- > findAllByA11yTraits
169
+ const { getByRole } = render (< View accessibilityRole= " summary" / > );
206
170
207
- ``` typescript
208
- getByA11yTraits (
209
- container : ReactTestRendererInstance ,
210
- match : Array < string > ,
211
- ): FiberRoot
171
+ getByRole (' summary' ); // returns the View node
212
172
```
213
173
214
- This will search for all elements with an ` accessibilityTraits ` prop and find one that matches the
215
- given ` Array ` .
174
+ > ` ByRole ` queries will fall back to searching for elements with an ` accessibilityTraits ` match, but
175
+ > they will log a warning on all matches that this prop is being deprecated by react-native .
216
176
217
- ``` js
218
- import { render } from ' react-testing-library' ;
219
-
220
- const { getByA11yTraits } = render (< View accessibilityTraits= {[' button' ]} / > );
221
-
222
- getByA11yTraits ([' button' ]); // returns the View node
223
- ```
177
+ ### ` ByPlaceholderText `
224
178
225
- ### ` ByPlaceholder `
226
-
227
- > getByPlaceholder, queryByPlaceholder, getAllByPlaceholder, queryAllByPlaceholder,
228
- > findByPlaceholder, findAllByPlaceholder
179
+ > getByPlaceholderText, queryByPlaceholderText, getAllByPlaceholderText, queryAllByPlaceholderText,
180
+ > findByPlaceholderText, findAllByPlaceholderText
229
181
230
182
``` typescript
231
- getByPlaceholder (
232
- container : ReactTestRendererInstance ,
183
+ getByPlaceholderText (
184
+ testRenderer : ReactTestRendererInstance ,
233
185
match : TextMatch ,
234
186
options ?: {
235
187
exact?: boolean = true ,
236
188
trim?: boolean = true ,
237
189
collapseWhitespace?: boolean = true ,
238
- filter ?: FilterFn ,
190
+ selector ?: SelectorFn ,
239
191
normalizer?: NormalizerFn ,
240
- }): FiberRoot
192
+ }): NativeTestInstance
241
193
```
242
194
243
195
This will search for all elements with a ` placeholder ` prop and find one that matches the given
@@ -246,9 +198,9 @@ This will search for all elements with a `placeholder` prop and find one that ma
246
198
``` javascript
247
199
import { render } from ' native-testing-library' ;
248
200
249
- const { getByPlaceholder } = render (< TextInput placeholder= " Username" / > );
201
+ const { getByPlaceholderText } = render (< TextInput placeholder= " Username" / > );
250
202
251
- getByPlaceholder (' Username' ); // returns the TextInput node
203
+ getByPlaceholderText (' Username' ); // returns the TextInput node
252
204
```
253
205
254
206
### ` ByText `
@@ -257,18 +209,20 @@ getByPlaceholder('Username'); // returns the TextInput node
257
209
258
210
``` typescript
259
211
getByText (
260
- container : ReactTestRendererInstance ,
212
+ testRenderer : ReactTestRendererInstance ,
261
213
match : TextMatch ,
262
214
options ?: {
215
+ exact?: boolean = true ,
263
216
trim?: boolean = true ,
264
217
collapseWhitespace?: boolean = true ,
265
- exact ?: boolean = true ,
218
+ selector ?: SelectorFn ,
266
219
normalizer?: NormalizerFn ,
267
- }): FiberRoot
220
+ }): NativeTestInstance
268
221
```
269
222
270
223
This will search for all elements of type ` Text ` with ` props.children ` matching the given. It will
271
- also search ` TextInput ` elements by their value [ ` TextMatch ` ] ( #textmatch ) .
224
+ also search ` TextInput ` elements by their value and ` Button ` elements by their ` title `
225
+ [ ` TextMatch ` ] ( #textmatch ) .
272
226
273
227
``` js
274
228
import { render } from ' native-testing-library' ;
@@ -284,18 +238,19 @@ getByText(/about/i); // returns the Text node
284
238
285
239
``` typescript
286
240
getByTitle (
287
- container : ReactTestRendererInstance ,
241
+ testRenderer : ReactTestRendererInstance ,
288
242
match : TextMatch ,
289
243
options ?: {
244
+ exact?: boolean = true ,
290
245
trim?: boolean = true ,
291
246
collapseWhitespace?: boolean = true ,
292
- exact ?: boolean = true ,
247
+ selector ?: SelectorFn ,
293
248
normalizer?: NormalizerFn ,
294
- }): FiberRoot
249
+ }): NativeTestInstance
295
250
```
296
251
297
- This will search for all elements with ` props.title ` matching the given by their value
298
- [ ` TextMatch ` ] ( #textmatch ) .
252
+ This will search for all ` Button ` or ` RefreshControl ` elements with ` props.title ` matching the given
253
+ by their value [ ` TextMatch ` ] ( #textmatch ) .
299
254
300
255
``` js
301
256
import { render } from ' native-testing-library' ;
@@ -311,19 +266,19 @@ getByTitle(/about/i); // returns the Button node
311
266
312
267
``` typescript
313
268
getByValue (
314
- container : ReactTestRendererInstance ,
269
+ testRenderer : ReactTestRendererInstance ,
315
270
match : TextMatch ,
316
271
options ?: {
317
272
exact?: boolean = true ,
318
273
trim?: boolean = true ,
319
274
collapseWhitespace?: boolean = true ,
320
- filter ?: FilterFn ,
275
+ selector ?: SelectorFn ,
321
276
normalizer?: NormalizerFn ,
322
277
}): NormalizerOptions
323
278
```
324
279
325
- This will search for all elements with a ` value ` prop and find one that matches the given
326
- [ ` TextMatch ` ] ( #textmatch ) .
280
+ This will search for all ` TextInput ` elements with a ` value ` prop or ` Picker ` elements with a
281
+ ` selectedValue ` prop and find ones that matches the given [ ` TextMatch ` ] ( #textmatch ) .
327
282
328
283
``` js
329
284
import { render } from ' native-testing-library' ;
@@ -339,15 +294,15 @@ getByValue(/about/i); // returns the Input node
339
294
340
295
``` typescript
341
296
getByTestId (
342
- container : ReactTestRendererInstance ,
297
+ testRenderer : ReactTestRendererInstance ,
343
298
match : TextMatch ,
344
299
options ?: {
345
300
trim?: boolean = true ,
346
301
collapseWhitespace?: boolean = true ,
347
302
exact?: boolean = true ,
348
- filter ?: FilterFn ,
303
+ selector ?: SelectorFn ,
349
304
normalizer?: NormalizerFn ,
350
- }): FiberRoot
305
+ }): NativeTestInstance
351
306
```
352
307
353
308
This will search for all elements with a ` testID ` and find one that matches the given
0 commit comments