@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.
- package/README.md +23 -3
- package/build/fireEvent.js +5 -13
- package/build/fireEvent.js.flow +5 -22
- package/build/flushMicroTasks.js +3 -1
- package/build/flushMicroTasks.js.flow +1 -0
- package/build/helpers/byDisplayValue.js +10 -4
- package/build/helpers/byDisplayValue.js.flow +15 -5
- package/build/helpers/byPlaceholderText.js +10 -4
- package/build/helpers/byPlaceholderText.js.flow +15 -7
- package/build/helpers/byTestId.js +10 -4
- package/build/helpers/byTestId.js.flow +11 -7
- package/build/helpers/byText.js +13 -6
- package/build/helpers/byText.js.flow +25 -9
- package/build/helpers/errors.js +2 -1
- package/build/helpers/errors.js.flow +1 -0
- package/build/helpers/findByAPI.js.flow +9 -0
- package/build/helpers/getByAPI.js.flow +31 -8
- package/build/helpers/makeQueries.js +40 -10
- package/build/helpers/makeQueries.js.flow +61 -10
- package/build/helpers/queryByAPI.js.flow +23 -8
- package/build/helpers/timers.js +77 -0
- package/build/helpers/timers.js.flow +88 -0
- package/build/matches.js +33 -0
- package/build/matches.js.flow +41 -0
- package/build/pure.js +8 -0
- package/build/pure.js.flow +2 -0
- package/build/render.js +9 -2
- package/build/render.js.flow +7 -2
- package/build/waitFor.js +147 -21
- package/build/waitFor.js.flow +154 -20
- package/jest-preset/index.js +10 -0
- package/jest-preset/restore-promise.js +1 -0
- package/jest-preset/save-promise.js +1 -0
- package/package.json +16 -11
- package/typings/index.d.ts +106 -51
package/typings/index.d.ts
CHANGED
|
@@ -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:
|
|
19
|
-
getByPlaceholderText: (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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:
|
|
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: (
|
|
88
|
+
queryByText: (
|
|
89
|
+
name: TextMatch,
|
|
90
|
+
options?: TextMatchOptions
|
|
91
|
+
) => ReactTestInstance | null;
|
|
68
92
|
queryByPlaceholderText: (
|
|
69
|
-
placeholder:
|
|
93
|
+
placeholder: TextMatch,
|
|
94
|
+
options?: TextMatchOptions
|
|
95
|
+
) => ReactTestInstance | null;
|
|
96
|
+
queryByDisplayValue: (
|
|
97
|
+
value: TextMatch,
|
|
98
|
+
options?: TextMatchOptions
|
|
70
99
|
) => ReactTestInstance | null;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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:
|
|
107
|
+
placeholder: TextMatch,
|
|
108
|
+
options?: TextMatchOptions
|
|
77
109
|
) => Array<ReactTestInstance> | [];
|
|
78
110
|
queryAllByDisplayValue: (
|
|
79
|
-
value:
|
|
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:
|
|
162
|
+
text: TextMatch,
|
|
163
|
+
queryOptions?: TextMatchOptions,
|
|
130
164
|
waitForOptions?: WaitForOptions
|
|
131
165
|
) => FindReturn;
|
|
132
166
|
findByPlaceholderText: (
|
|
133
|
-
placeholder:
|
|
167
|
+
placeholder: TextMatch,
|
|
168
|
+
queryOptions?: TextMatchOptions,
|
|
134
169
|
waitForOptions?: WaitForOptions
|
|
135
170
|
) => FindReturn;
|
|
136
171
|
findByDisplayValue: (
|
|
137
|
-
value:
|
|
172
|
+
value: TextMatch,
|
|
173
|
+
queryOptions?: TextMatchOptions,
|
|
138
174
|
waitForOptions?: WaitForOptions
|
|
139
175
|
) => FindReturn;
|
|
140
176
|
findByTestId: (
|
|
141
|
-
testID:
|
|
177
|
+
testID: TextMatch,
|
|
178
|
+
queryOptions?: TextMatchOptions,
|
|
142
179
|
waitForOptions?: WaitForOptions
|
|
143
180
|
) => FindReturn;
|
|
144
181
|
findAllByText: (
|
|
145
|
-
text:
|
|
182
|
+
text: TextMatch,
|
|
183
|
+
queryOptions?: TextMatchOptions,
|
|
146
184
|
waitForOptions?: WaitForOptions
|
|
147
185
|
) => FindAllReturn;
|
|
148
186
|
findAllByPlaceholderText: (
|
|
149
|
-
placeholder:
|
|
187
|
+
placeholder: TextMatch,
|
|
188
|
+
queryOptions?: TextMatchOptions,
|
|
150
189
|
waitForOptions?: WaitForOptions
|
|
151
190
|
) => FindAllReturn;
|
|
152
191
|
findAllByDisplayValue: (
|
|
153
|
-
value:
|
|
192
|
+
value: TextMatch,
|
|
193
|
+
queryOptions?: TextMatchOptions,
|
|
154
194
|
waitForOptions?: WaitForOptions
|
|
155
195
|
) => FindAllReturn;
|
|
156
196
|
findAllByTestId: (
|
|
157
|
-
testID:
|
|
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:
|
|
173
|
-
getByLabelText: (matcher:
|
|
174
|
-
getAllByA11yLabel: (matcher:
|
|
175
|
-
getAllByLabelText: (matcher:
|
|
176
|
-
queryByA11yLabel: (matcher:
|
|
177
|
-
queryByLabelText: (matcher:
|
|
178
|
-
queryAllByA11yLabel: (matcher:
|
|
179
|
-
queryAllByLabelText: (matcher:
|
|
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:
|
|
222
|
+
matcher: TextMatch,
|
|
182
223
|
waitForOptions?: WaitForOptions
|
|
183
224
|
) => FindReturn;
|
|
184
225
|
findByLabelText: (
|
|
185
|
-
matcher:
|
|
226
|
+
matcher: TextMatch,
|
|
186
227
|
waitForOptions?: WaitForOptions
|
|
187
228
|
) => FindReturn;
|
|
188
229
|
findAllByA11yLabel: (
|
|
189
|
-
matcher:
|
|
230
|
+
matcher: TextMatch,
|
|
190
231
|
waitForOptions?: WaitForOptions
|
|
191
232
|
) => FindAllReturn;
|
|
192
233
|
findAllByLabelText: (
|
|
193
|
-
matcher:
|
|
234
|
+
matcher: TextMatch,
|
|
194
235
|
waitForOptions?: WaitForOptions
|
|
195
236
|
) => FindAllReturn;
|
|
196
237
|
|
|
197
238
|
// Hint
|
|
198
|
-
getByA11yHint: (matcher:
|
|
199
|
-
getByHintText: (matcher:
|
|
200
|
-
getAllByA11yHint: (matcher:
|
|
201
|
-
getAllByHintText: (matcher:
|
|
202
|
-
queryByA11yHint: (matcher:
|
|
203
|
-
queryByHintText: (matcher:
|
|
204
|
-
queryAllByA11yHint: (matcher:
|
|
205
|
-
queryAllByHintText: (matcher:
|
|
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:
|
|
248
|
+
matcher: TextMatch,
|
|
208
249
|
waitForOptions?: WaitForOptions
|
|
209
250
|
) => FindReturn;
|
|
210
251
|
findByHintText: (
|
|
211
|
-
matcher:
|
|
252
|
+
matcher: TextMatch,
|
|
212
253
|
waitForOptions?: WaitForOptions
|
|
213
254
|
) => FindReturn;
|
|
214
255
|
findAllByA11yHint: (
|
|
215
|
-
matcher:
|
|
256
|
+
matcher: TextMatch,
|
|
216
257
|
waitForOptions?: WaitForOptions
|
|
217
258
|
) => FindAllReturn;
|
|
218
259
|
findAllByHintText: (
|
|
219
|
-
matcher:
|
|
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
|
*/
|