@testing-library/react-native 7.2.0 → 9.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,17 +14,38 @@ type QueryAllReturn = Array<ReactTestInstance> | [];
14
14
  type FindReturn = Promise<ReactTestInstance>;
15
15
  type FindAllReturn = Promise<ReactTestInstance[]>;
16
16
 
17
+ type TextMatch = string | RegExp;
18
+
17
19
  interface GetByAPI {
18
- getByText: (text: string | RegExp) => ReactTestInstance;
19
- getByPlaceholderText: (placeholder: string | RegExp) => ReactTestInstance;
20
- getByDisplayValue: (value: string | RegExp) => ReactTestInstance;
21
- getByTestId: (testID: string | RegExp) => ReactTestInstance;
22
- getAllByTestId: (testID: string | RegExp) => Array<ReactTestInstance>;
23
- getAllByText: (text: string | RegExp) => Array<ReactTestInstance>;
20
+ getByText: (text: TextMatch, options?: TextMatchOptions) => ReactTestInstance;
21
+ getByPlaceholderText: (
22
+ placeholder: TextMatch,
23
+ options?: TextMatchOptions
24
+ ) => ReactTestInstance;
25
+ getByDisplayValue: (
26
+ value: TextMatch,
27
+ options?: TextMatchOptions
28
+ ) => ReactTestInstance;
29
+ getByTestId: (
30
+ testID: TextMatch,
31
+ options?: TextMatchOptions
32
+ ) => ReactTestInstance;
33
+ getAllByTestId: (
34
+ testID: TextMatch,
35
+ options?: TextMatchOptions
36
+ ) => Array<ReactTestInstance>;
37
+ getAllByText: (
38
+ text: TextMatch,
39
+ options?: TextMatchOptions
40
+ ) => Array<ReactTestInstance>;
24
41
  getAllByPlaceholderText: (
25
- placeholder: string | RegExp
42
+ placeholder: TextMatch,
43
+ options?: TextMatchOptions
44
+ ) => Array<ReactTestInstance>;
45
+ getAllByDisplayValue: (
46
+ value: TextMatch,
47
+ options?: TextMatchOptions
26
48
  ) => Array<ReactTestInstance>;
27
- getAllByDisplayValue: (value: string | RegExp) => Array<ReactTestInstance>;
28
49
 
29
50
  // Unsafe aliases
30
51
  UNSAFE_getByType: <P>(type: React.ComponentType<P>) => ReactTestInstance;
@@ -64,19 +85,31 @@ interface GetByAPI {
64
85
  }
65
86
 
66
87
  interface QueryByAPI {
67
- queryByText: (name: string | RegExp) => ReactTestInstance | null;
88
+ queryByText: (
89
+ name: TextMatch,
90
+ options?: TextMatchOptions
91
+ ) => ReactTestInstance | null;
68
92
  queryByPlaceholderText: (
69
- placeholder: string | RegExp
93
+ placeholder: TextMatch,
94
+ options?: TextMatchOptions
95
+ ) => ReactTestInstance | null;
96
+ queryByDisplayValue: (
97
+ value: TextMatch,
98
+ options?: TextMatchOptions
70
99
  ) => ReactTestInstance | null;
71
- queryByDisplayValue: (value: string | RegExp) => ReactTestInstance | null;
72
- queryByTestId: (testID: string | RegExp) => ReactTestInstance | null;
73
- queryAllByTestId: (testID: string | RegExp) => Array<ReactTestInstance> | [];
74
- queryAllByText: (text: string | RegExp) => Array<ReactTestInstance> | [];
100
+ queryByTestId: (testID: TextMatch) => ReactTestInstance | null;
101
+ queryAllByTestId: (testID: TextMatch) => Array<ReactTestInstance> | [];
102
+ queryAllByText: (
103
+ text: TextMatch,
104
+ options?: TextMatchOptions
105
+ ) => Array<ReactTestInstance> | [];
75
106
  queryAllByPlaceholderText: (
76
- placeholder: string | RegExp
107
+ placeholder: TextMatch,
108
+ options?: TextMatchOptions
77
109
  ) => Array<ReactTestInstance> | [];
78
110
  queryAllByDisplayValue: (
79
- value: string | RegExp
111
+ value: TextMatch,
112
+ options?: TextMatchOptions
80
113
  ) => Array<ReactTestInstance> | [];
81
114
 
82
115
  // Unsafe aliases
@@ -126,35 +159,43 @@ interface QueryByAPI {
126
159
 
127
160
  interface FindByAPI {
128
161
  findByText: (
129
- text: string | RegExp,
162
+ text: TextMatch,
163
+ queryOptions?: TextMatchOptions,
130
164
  waitForOptions?: WaitForOptions
131
165
  ) => FindReturn;
132
166
  findByPlaceholderText: (
133
- placeholder: string | RegExp,
167
+ placeholder: TextMatch,
168
+ queryOptions?: TextMatchOptions,
134
169
  waitForOptions?: WaitForOptions
135
170
  ) => FindReturn;
136
171
  findByDisplayValue: (
137
- value: string | RegExp,
172
+ value: TextMatch,
173
+ queryOptions?: TextMatchOptions,
138
174
  waitForOptions?: WaitForOptions
139
175
  ) => FindReturn;
140
176
  findByTestId: (
141
- testID: string | RegExp,
177
+ testID: TextMatch,
178
+ queryOptions?: TextMatchOptions,
142
179
  waitForOptions?: WaitForOptions
143
180
  ) => FindReturn;
144
181
  findAllByText: (
145
- text: string | RegExp,
182
+ text: TextMatch,
183
+ queryOptions?: TextMatchOptions,
146
184
  waitForOptions?: WaitForOptions
147
185
  ) => FindAllReturn;
148
186
  findAllByPlaceholderText: (
149
- placeholder: string | RegExp,
187
+ placeholder: TextMatch,
188
+ queryOptions?: TextMatchOptions,
150
189
  waitForOptions?: WaitForOptions
151
190
  ) => FindAllReturn;
152
191
  findAllByDisplayValue: (
153
- value: string | RegExp,
192
+ value: TextMatch,
193
+ queryOptions?: TextMatchOptions,
154
194
  waitForOptions?: WaitForOptions
155
195
  ) => FindAllReturn;
156
196
  findAllByTestId: (
157
- testID: string | RegExp,
197
+ testID: TextMatch,
198
+ queryOptions?: TextMatchOptions,
158
199
  waitForOptions?: WaitForOptions
159
200
  ) => FindAllReturn;
160
201
  }
@@ -169,54 +210,54 @@ export type A11yValue = {
169
210
 
170
211
  type A11yAPI = {
171
212
  // Label
172
- getByA11yLabel: (matcher: string | RegExp) => GetReturn;
173
- getByLabelText: (matcher: string | RegExp) => GetReturn;
174
- getAllByA11yLabel: (matcher: string | RegExp) => GetAllReturn;
175
- getAllByLabelText: (matcher: string | RegExp) => GetAllReturn;
176
- queryByA11yLabel: (matcher: string | RegExp) => QueryReturn;
177
- queryByLabelText: (matcher: string | RegExp) => QueryReturn;
178
- queryAllByA11yLabel: (matcher: string | RegExp) => QueryAllReturn;
179
- queryAllByLabelText: (matcher: string | RegExp) => QueryAllReturn;
213
+ getByA11yLabel: (matcher: TextMatch) => GetReturn;
214
+ getByLabelText: (matcher: TextMatch) => GetReturn;
215
+ getAllByA11yLabel: (matcher: TextMatch) => GetAllReturn;
216
+ getAllByLabelText: (matcher: TextMatch) => GetAllReturn;
217
+ queryByA11yLabel: (matcher: TextMatch) => QueryReturn;
218
+ queryByLabelText: (matcher: TextMatch) => QueryReturn;
219
+ queryAllByA11yLabel: (matcher: TextMatch) => QueryAllReturn;
220
+ queryAllByLabelText: (matcher: TextMatch) => QueryAllReturn;
180
221
  findByA11yLabel: (
181
- matcher: string | RegExp,
222
+ matcher: TextMatch,
182
223
  waitForOptions?: WaitForOptions
183
224
  ) => FindReturn;
184
225
  findByLabelText: (
185
- matcher: string | RegExp,
226
+ matcher: TextMatch,
186
227
  waitForOptions?: WaitForOptions
187
228
  ) => FindReturn;
188
229
  findAllByA11yLabel: (
189
- matcher: string | RegExp,
230
+ matcher: TextMatch,
190
231
  waitForOptions?: WaitForOptions
191
232
  ) => FindAllReturn;
192
233
  findAllByLabelText: (
193
- matcher: string | RegExp,
234
+ matcher: TextMatch,
194
235
  waitForOptions?: WaitForOptions
195
236
  ) => FindAllReturn;
196
237
 
197
238
  // Hint
198
- getByA11yHint: (matcher: string | RegExp) => GetReturn;
199
- getByHintText: (matcher: string | RegExp) => GetReturn;
200
- getAllByA11yHint: (matcher: string | RegExp) => GetAllReturn;
201
- getAllByHintText: (matcher: string | RegExp) => GetAllReturn;
202
- queryByA11yHint: (matcher: string | RegExp) => QueryReturn;
203
- queryByHintText: (matcher: string | RegExp) => QueryReturn;
204
- queryAllByA11yHint: (matcher: string | RegExp) => QueryAllReturn;
205
- queryAllByHintText: (matcher: string | RegExp) => QueryAllReturn;
239
+ getByA11yHint: (matcher: TextMatch) => GetReturn;
240
+ getByHintText: (matcher: TextMatch) => GetReturn;
241
+ getAllByA11yHint: (matcher: TextMatch) => GetAllReturn;
242
+ getAllByHintText: (matcher: TextMatch) => GetAllReturn;
243
+ queryByA11yHint: (matcher: TextMatch) => QueryReturn;
244
+ queryByHintText: (matcher: TextMatch) => QueryReturn;
245
+ queryAllByA11yHint: (matcher: TextMatch) => QueryAllReturn;
246
+ queryAllByHintText: (matcher: TextMatch) => QueryAllReturn;
206
247
  findByA11yHint: (
207
- matcher: string | RegExp,
248
+ matcher: TextMatch,
208
249
  waitForOptions?: WaitForOptions
209
250
  ) => FindReturn;
210
251
  findByHintText: (
211
- matcher: string | RegExp,
252
+ matcher: TextMatch,
212
253
  waitForOptions?: WaitForOptions
213
254
  ) => FindReturn;
214
255
  findAllByA11yHint: (
215
- matcher: string | RegExp,
256
+ matcher: TextMatch,
216
257
  waitForOptions?: WaitForOptions
217
258
  ) => FindAllReturn;
218
259
  findAllByHintText: (
219
- matcher: string | RegExp,
260
+ matcher: TextMatch,
220
261
  waitForOptions?: WaitForOptions
221
262
  ) => FindAllReturn;
222
263
 
@@ -299,7 +340,7 @@ export interface RenderOptions {
299
340
  }
300
341
 
301
342
  type Debug = {
302
- (message?: string);
343
+ (message?: string): void;
303
344
  shallow: (message?: string) => void;
304
345
  };
305
346
 
@@ -309,7 +350,7 @@ export interface RenderAPI extends Queries {
309
350
  update(nextElement: React.ReactElement<any>): void;
310
351
  rerender(nextElement: React.ReactElement<any>): void;
311
352
  unmount(nextElement?: React.ReactElement<any>): void;
312
- toJSON(): ReactTestRendererJSON | null;
353
+ toJSON(): ReactTestRendererJSON[] | ReactTestRendererJSON | null;
313
354
  debug: Debug;
314
355
  container: ReactTestInstance;
315
356
  }
@@ -321,7 +362,7 @@ export type FireEventFunction = (
321
362
  ) => any;
322
363
 
323
364
  export type FireEventAPI = FireEventFunction & {
324
- press: (element: ReactTestInstance) => any;
365
+ press: (element: ReactTestInstance, ...data: Array<any>) => any;
325
366
  changeText: (element: ReactTestInstance, ...data: Array<any>) => any;
326
367
  scroll: (element: ReactTestInstance, ...data: Array<any>) => any;
327
368
  };
@@ -334,6 +375,16 @@ export declare const render: (
334
375
  export declare const cleanup: () => void;
335
376
  export declare const fireEvent: FireEventAPI;
336
377
 
378
+ type NormalizerFn = (textToNormalize: string) => string;
379
+ type NormalizerConfig = {
380
+ trim?: boolean;
381
+ collapseWhitespace?: boolean;
382
+ };
383
+ type TextMatchOptions = {
384
+ exact?: boolean;
385
+ normalizer?: NormalizerFn;
386
+ };
387
+
337
388
  type WaitForOptions = {
338
389
  timeout?: number;
339
390
  interval?: number;
@@ -359,6 +410,10 @@ export declare const getQueriesForElement: (
359
410
  instance: ReactTestInstance
360
411
  ) => Queries;
361
412
 
413
+ export declare const getDefaultNormalizer: (
414
+ normalizerConfig?: NormalizerConfig
415
+ ) => NormalizerFn;
416
+
362
417
  /**
363
418
  * @deprecated This function has been removed. Please use `waitFor` function.
364
419
  */