@testing-library/react-native 14.0.0-alpha.3 → 14.0.0-alpha.5
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/build/act.d.ts +2 -2
- package/build/act.js +6 -3
- package/build/act.js.map +1 -1
- package/build/cleanup.d.ts +3 -5
- package/build/cleanup.js +2 -8
- package/build/cleanup.js.map +1 -1
- package/build/fire-event.d.ts +9 -9
- package/build/fire-event.js +21 -16
- package/build/fire-event.js.map +1 -1
- package/build/helpers/host-component-names.d.ts +1 -0
- package/build/helpers/host-component-names.js +2 -1
- package/build/helpers/host-component-names.js.map +1 -1
- package/build/helpers/timers.d.ts +3 -1
- package/build/helpers/timers.js +3 -1
- package/build/helpers/timers.js.map +1 -1
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build/pure.d.ts +11 -11
- package/build/pure.js +35 -37
- package/build/pure.js.map +1 -1
- package/build/queries/make-queries.js +3 -4
- package/build/queries/make-queries.js.map +1 -1
- package/build/render-hook.d.ts +9 -7
- package/build/render-hook.js +18 -15
- package/build/render-hook.js.map +1 -1
- package/build/render.d.ts +8 -77
- package/build/render.js +23 -40
- package/build/render.js.map +1 -1
- package/build/screen.js +1 -4
- package/build/screen.js.map +1 -1
- package/build/test-utils/version.d.ts +7 -0
- package/build/test-utils/version.js +18 -0
- package/build/test-utils/version.js.map +1 -0
- package/build/tsconfig.release.tsbuildinfo +1 -1
- package/build/types.js +4 -0
- package/build/unsafe-render-sync.d.ts +144 -0
- package/build/{render-async.js → unsafe-render-sync.js} +49 -31
- package/build/unsafe-render-sync.js.map +1 -0
- package/build/user-event/press/press.js +2 -3
- package/build/user-event/press/press.js.map +1 -1
- package/build/user-event/utils/dispatch-event.js +2 -5
- package/build/user-event/utils/dispatch-event.js.map +1 -1
- package/build/user-event/utils/text-range.js +4 -0
- package/build/wait-for-element-to-be-removed.d.ts +1 -1
- package/build/wait-for-element-to-be-removed.js +3 -4
- package/build/wait-for-element-to-be-removed.js.map +1 -1
- package/build/wait-for.d.ts +1 -1
- package/build/wait-for.js +6 -7
- package/build/wait-for.js.map +1 -1
- package/package.json +9 -12
- package/build/index.flow.js +0 -378
- package/build/render-act.d.ts +0 -3
- package/build/render-act.js +0 -29
- package/build/render-act.js.map +0 -1
- package/build/render-async.d.ts +0 -83
- package/build/render-async.js.map +0 -1
- package/typings/index.flow.js +0 -378
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"render-async.js","names":["React","_interopRequireWildcard","require","_act","_interopRequireDefault","_cleanup","_config","_debug","_errors","_renderAct","_screen","_within","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","renderAsync","component","options","wrapper","Wrapper","rendererOptions","wrap","element","createElement","renderer","renderWithAsyncAct","buildRenderResult","container","rerender","_component","ErrorWithStack","rerenderAsync","act","render","unmount","unmountAsync","addToCleanupQueue","result","getQueriesForElement","update","updateAsync","toJSON","debug","makeDebug","root","firstChild","children","Error","setRenderResult","debugImpl","defaultDebugOptions","getConfig","debugOptions","json"],"sources":["../src/render-async.tsx"],"sourcesContent":["import * as React from 'react';\nimport type { HostElement, Root, RootOptions } from 'universal-test-renderer';\n\nimport act from './act';\nimport { addToCleanupQueue } from './cleanup';\nimport { getConfig } from './config';\nimport type { DebugOptions } from './helpers/debug';\nimport { debug } from './helpers/debug';\nimport { ErrorWithStack } from './helpers/errors';\nimport { renderWithAsyncAct } from './render-act';\nimport { setRenderResult } from './screen';\nimport { getQueriesForElement } from './within';\n\nexport interface RenderAsyncOptions {\n /**\n * Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating\n * reusable custom render functions for common data providers.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n wrapper?: React.ComponentType<any>;\n\n createNodeMock?: (element: React.ReactElement) => unknown;\n}\n\nexport type RenderAsyncResult = ReturnType<typeof renderAsync>;\n\n/**\n * Renders test component deeply using React Test Renderer and exposes helpers\n * to assert on the output.\n */\nexport default async function renderAsync<T>(\n component: React.ReactElement<T>,\n options: RenderAsyncOptions = {},\n) {\n const { wrapper: Wrapper } = options || {};\n\n // TODO allow passing some options\n const rendererOptions: RootOptions = {};\n\n const wrap = (element: React.ReactElement) => (Wrapper ? <Wrapper>{element}</Wrapper> : element);\n const renderer = await renderWithAsyncAct(wrap(component), rendererOptions);\n return buildRenderResult(renderer, wrap);\n}\n\nfunction buildRenderResult(\n renderer: Root,\n wrap: (element: React.ReactElement) => React.JSX.Element,\n) {\n const container = renderer.container;\n\n const rerender = (_component: React.ReactElement) => {\n throw new ErrorWithStack(\n '\"rerender(...)\" is not supported when using \"renderAsync\" use \"await rerenderAsync(...)\" instead',\n rerender,\n );\n };\n const rerenderAsync = async (component: React.ReactElement) => {\n // eslint-disable-next-line require-await\n await act(async () => {\n renderer.render(wrap(component));\n });\n };\n\n const unmount = () => {\n throw new ErrorWithStack(\n '\"unmount()\" is not supported when using \"renderAsync\" use \"await unmountAsync()\" instead',\n unmount,\n );\n };\n const unmountAsync = async () => {\n // eslint-disable-next-line require-await\n await act(async () => {\n renderer.unmount();\n });\n };\n\n addToCleanupQueue(unmountAsync);\n\n const result = {\n ...getQueriesForElement(renderer.container),\n rerender,\n rerenderAsync,\n update: rerender, // alias for `rerender`\n updateAsync: rerenderAsync, // alias for `rerenderAsync`\n unmount,\n unmountAsync,\n toJSON: () => renderer.container.toJSON(),\n debug: makeDebug(renderer),\n get container(): HostElement {\n return renderer.container;\n },\n get root(): HostElement | null {\n const firstChild = container.children[0];\n if (typeof firstChild === 'string') {\n throw new Error(\n 'Invariant Violation: Root element must be a host element. Detected attempt to render a string within the root element.',\n );\n }\n\n return firstChild;\n },\n };\n\n setRenderResult(result);\n\n return result;\n}\n\nexport type DebugFunction = (options?: DebugOptions) => void;\n\nfunction makeDebug(renderer: Root): DebugFunction {\n function debugImpl(options?: DebugOptions) {\n const { defaultDebugOptions } = getConfig();\n const debugOptions = { ...def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AAO,IAAAX,YAAK,EAACW,IAAI,EAAED,YAAY,CAAC;IAClC;EACF;EACA,OAAOH,SAAS;AAClB","ignoreList":[]}
|
package/typings/index.flow.js
DELETED
|
@@ -1,378 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
|
|
4
|
-
type GetReturn = ReactTestInstance;
|
|
5
|
-
type GetAllReturn = Array<ReactTestInstance>;
|
|
6
|
-
type QueryReturn = ReactTestInstance | null;
|
|
7
|
-
type QueryAllReturn = Array<ReactTestInstance> | [];
|
|
8
|
-
type FindReturn = Promise<ReactTestInstance>;
|
|
9
|
-
type FindAllReturn = Promise<ReactTestInstance[]>;
|
|
10
|
-
|
|
11
|
-
type CommonQueryOptions = {
|
|
12
|
-
includeHiddenElements?: boolean,
|
|
13
|
-
hidden?: boolean,
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
type TextMatch = string | RegExp;
|
|
17
|
-
|
|
18
|
-
declare type NormalizerFn = (textToNormalize: string) => string;
|
|
19
|
-
declare type NormalizerConfig = {
|
|
20
|
-
trim?: boolean,
|
|
21
|
-
collapseWhitespace?: boolean,
|
|
22
|
-
};
|
|
23
|
-
declare type TextMatchOptions = {
|
|
24
|
-
exact?: boolean,
|
|
25
|
-
normalizer?: NormalizerFn,
|
|
26
|
-
};
|
|
27
|
-
declare type A11yRole =
|
|
28
|
-
| 'none'
|
|
29
|
-
| 'button'
|
|
30
|
-
| 'link'
|
|
31
|
-
| 'search'
|
|
32
|
-
| 'image'
|
|
33
|
-
| 'keyboardkey'
|
|
34
|
-
| 'text'
|
|
35
|
-
| 'adjustable'
|
|
36
|
-
| 'imagebutton'
|
|
37
|
-
| 'header'
|
|
38
|
-
| 'summary'
|
|
39
|
-
| 'alert'
|
|
40
|
-
| 'checkbox'
|
|
41
|
-
| 'combobox'
|
|
42
|
-
| 'menu'
|
|
43
|
-
| 'menubar'
|
|
44
|
-
| 'menuitem'
|
|
45
|
-
| 'progressbar'
|
|
46
|
-
| 'radio'
|
|
47
|
-
| 'radiogroup'
|
|
48
|
-
| 'scrollbar'
|
|
49
|
-
| 'spinbutton'
|
|
50
|
-
| 'switch'
|
|
51
|
-
| 'tab'
|
|
52
|
-
| 'tablist'
|
|
53
|
-
| 'timer'
|
|
54
|
-
| 'toolbar';
|
|
55
|
-
|
|
56
|
-
declare type A11yState = {|
|
|
57
|
-
disabled?: boolean,
|
|
58
|
-
selected?: boolean,
|
|
59
|
-
checked?: boolean | 'mixed',
|
|
60
|
-
busy?: boolean,
|
|
61
|
-
expanded?: boolean,
|
|
62
|
-
|};
|
|
63
|
-
|
|
64
|
-
declare type A11yValue = {
|
|
65
|
-
min?: number,
|
|
66
|
-
max?: number,
|
|
67
|
-
now?: number,
|
|
68
|
-
text?: TextMatch,
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
type WaitForOptions = {
|
|
72
|
-
timeout?: number,
|
|
73
|
-
interval?: number,
|
|
74
|
-
onTimeout?: (error: Error) => Error,
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
type WaitForFunction = <T = any>(expectation: () => T, options?: WaitForOptions) => Promise<T>;
|
|
78
|
-
|
|
79
|
-
type ByTextOptions = CommonQueryOptions & TextMatchOptions;
|
|
80
|
-
|
|
81
|
-
interface ByTextQueries {
|
|
82
|
-
getByText: (text: TextMatch, options?: ByTextOptions) => ReactTestInstance;
|
|
83
|
-
getAllByText: (text: TextMatch, options?: ByTextOptions) => Array<ReactTestInstance>;
|
|
84
|
-
queryByText: (name: TextMatch, options?: ByTextOptions) => ReactTestInstance | null;
|
|
85
|
-
queryAllByText: (text: TextMatch, options?: ByTextOptions) => Array<ReactTestInstance> | [];
|
|
86
|
-
findByText: (
|
|
87
|
-
text: TextMatch,
|
|
88
|
-
queryOptions?: ByTextOptions,
|
|
89
|
-
waitForOptions?: WaitForOptions,
|
|
90
|
-
) => FindReturn;
|
|
91
|
-
findAllByText: (
|
|
92
|
-
text: TextMatch,
|
|
93
|
-
queryOptions?: ByTextOptions,
|
|
94
|
-
waitForOptions?: WaitForOptions,
|
|
95
|
-
) => FindAllReturn;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
type ByTestIdOptions = CommonQueryOptions & TextMatchOptions;
|
|
99
|
-
|
|
100
|
-
interface ByTestIdQueries {
|
|
101
|
-
getByTestId: (testID: TextMatch, options?: ByTestIdOptions) => ReactTestInstance;
|
|
102
|
-
getAllByTestId: (testID: TextMatch, options?: ByTestIdOptions) => Array<ReactTestInstance>;
|
|
103
|
-
queryByTestId: (testID: TextMatch, options?: ByTestIdOptions) => ReactTestInstance | null;
|
|
104
|
-
queryAllByTestId: (testID: TextMatch, options?: ByTestIdOptions) => Array<ReactTestInstance> | [];
|
|
105
|
-
findByTestId: (
|
|
106
|
-
testID: TextMatch,
|
|
107
|
-
queryOptions?: ByTestIdOptions,
|
|
108
|
-
waitForOptions?: WaitForOptions,
|
|
109
|
-
) => FindReturn;
|
|
110
|
-
findAllByTestId: (
|
|
111
|
-
testID: TextMatch,
|
|
112
|
-
queryOptions?: ByTestIdOptions,
|
|
113
|
-
waitForOptions?: WaitForOptions,
|
|
114
|
-
) => FindAllReturn;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
type ByDisplayValueOptions = CommonQueryOptions & TextMatchOptions;
|
|
118
|
-
|
|
119
|
-
interface ByDisplayValueQueries {
|
|
120
|
-
getByDisplayValue: (value: TextMatch, options?: ByDisplayValueOptions) => ReactTestInstance;
|
|
121
|
-
getAllByDisplayValue: (
|
|
122
|
-
value: TextMatch,
|
|
123
|
-
options?: ByDisplayValueOptions,
|
|
124
|
-
) => Array<ReactTestInstance>;
|
|
125
|
-
queryByDisplayValue: (
|
|
126
|
-
value: TextMatch,
|
|
127
|
-
options?: ByDisplayValueOptions,
|
|
128
|
-
) => ReactTestInstance | null;
|
|
129
|
-
queryAllByDisplayValue: (
|
|
130
|
-
value: TextMatch,
|
|
131
|
-
options?: ByDisplayValueOptions,
|
|
132
|
-
) => Array<ReactTestInstance> | [];
|
|
133
|
-
findByDisplayValue: (
|
|
134
|
-
value: TextMatch,
|
|
135
|
-
queryOptions?: ByDisplayValueOptions,
|
|
136
|
-
waitForOptions?: WaitForOptions,
|
|
137
|
-
) => FindReturn;
|
|
138
|
-
findAllByDisplayValue: (
|
|
139
|
-
value: TextMatch,
|
|
140
|
-
queryOptions?: ByDisplayValueOptions,
|
|
141
|
-
waitForOptions?: WaitForOptions,
|
|
142
|
-
) => FindAllReturn;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
type ByPlaceholderTextOptions = CommonQueryOptions & TextMatchOptions;
|
|
146
|
-
|
|
147
|
-
interface ByPlaceholderTextQueries {
|
|
148
|
-
getByPlaceholderText: (
|
|
149
|
-
placeholder: TextMatch,
|
|
150
|
-
options?: ByPlaceholderTextOptions,
|
|
151
|
-
) => ReactTestInstance;
|
|
152
|
-
getAllByPlaceholderText: (
|
|
153
|
-
placeholder: TextMatch,
|
|
154
|
-
options?: ByPlaceholderTextOptions,
|
|
155
|
-
) => Array<ReactTestInstance>;
|
|
156
|
-
queryByPlaceholderText: (
|
|
157
|
-
placeholder: TextMatch,
|
|
158
|
-
options?: ByPlaceholderTextOptions,
|
|
159
|
-
) => ReactTestInstance | null;
|
|
160
|
-
queryAllByPlaceholderText: (
|
|
161
|
-
placeholder: TextMatch,
|
|
162
|
-
options?: ByPlaceholderTextOptions,
|
|
163
|
-
) => Array<ReactTestInstance> | [];
|
|
164
|
-
findByPlaceholderText: (
|
|
165
|
-
placeholder: TextMatch,
|
|
166
|
-
queryOptions?: ByPlaceholderTextOptions,
|
|
167
|
-
waitForOptions?: WaitForOptions,
|
|
168
|
-
) => FindReturn;
|
|
169
|
-
findAllByPlaceholderText: (
|
|
170
|
-
placeholder: TextMatch,
|
|
171
|
-
queryOptions?: ByPlaceholderTextOptions,
|
|
172
|
-
waitForOptions?: WaitForOptions,
|
|
173
|
-
) => FindAllReturn;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
interface UnsafeByTypeQueries {
|
|
177
|
-
UNSAFE_getByType: <P>(type: React.ComponentType<P>) => ReactTestInstance;
|
|
178
|
-
UNSAFE_getAllByType: <P>(type: React.ComponentType<P>) => Array<ReactTestInstance>;
|
|
179
|
-
UNSAFE_queryByType: <P>(type: React.ComponentType<P>) => ReactTestInstance | null;
|
|
180
|
-
UNSAFE_queryAllByType: <P>(type: React.ComponentType<P>) => Array<ReactTestInstance> | [];
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
interface UnsafeByPropsQueries {
|
|
184
|
-
UNSAFE_getByProps: (props: { [string]: any }) => ReactTestInstance;
|
|
185
|
-
UNSAFE_getAllByProps: (props: { [string]: any }) => Array<ReactTestInstance>;
|
|
186
|
-
UNSAFE_queryByProps: (props: { [string]: any }) => ReactTestInstance | null;
|
|
187
|
-
UNSAFE_queryAllByProps: (props: { [string]: any }) => Array<ReactTestInstance> | [];
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
type ByRoleOptions = CommonQueryOptions & {
|
|
191
|
-
...A11yState,
|
|
192
|
-
name?: string,
|
|
193
|
-
value?: A11yValue,
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
type ByLabelTextOptions = CommonQueryOptions & TextMatchOptions;
|
|
197
|
-
type ByHintTextOptions = CommonQueryOptions & TextMatchOptions;
|
|
198
|
-
|
|
199
|
-
interface A11yAPI {
|
|
200
|
-
// Label
|
|
201
|
-
getByLabelText: (matcher: TextMatch, options?: ByLabelTextOptions) => GetReturn;
|
|
202
|
-
getAllByLabelText: (matcher: TextMatch, options?: ByLabelTextOptions) => GetAllReturn;
|
|
203
|
-
queryByLabelText: (matcher: TextMatch, options?: ByLabelTextOptions) => QueryReturn;
|
|
204
|
-
queryAllByLabelText: (matcher: TextMatch, options?: ByLabelTextOptions) => QueryAllReturn;
|
|
205
|
-
findByLabelText: (
|
|
206
|
-
matcher: TextMatch,
|
|
207
|
-
queryOptions?: ByLabelTextOptions,
|
|
208
|
-
waitForOptions?: WaitForOptions,
|
|
209
|
-
) => FindReturn;
|
|
210
|
-
findAllByLabelText: (
|
|
211
|
-
matcher: TextMatch,
|
|
212
|
-
queryOptions?: ByLabelTextOptions,
|
|
213
|
-
waitForOptions?: WaitForOptions,
|
|
214
|
-
) => FindAllReturn;
|
|
215
|
-
|
|
216
|
-
// Hint
|
|
217
|
-
getByA11yHint: (matcher: TextMatch, options?: ByHintTextOptions) => GetReturn;
|
|
218
|
-
getByHintText: (matcher: TextMatch, options?: ByHintTextOptions) => GetReturn;
|
|
219
|
-
getAllByA11yHint: (matcher: TextMatch, options?: ByHintTextOptions) => GetAllReturn;
|
|
220
|
-
getAllByHintText: (matcher: TextMatch, options?: ByHintTextOptions) => GetAllReturn;
|
|
221
|
-
queryByA11yHint: (matcher: TextMatch, options?: ByHintTextOptions) => QueryReturn;
|
|
222
|
-
queryByHintText: (matcher: TextMatch, options?: ByHintTextOptions) => QueryReturn;
|
|
223
|
-
queryAllByA11yHint: (matcher: TextMatch, options?: ByHintTextOptions) => QueryAllReturn;
|
|
224
|
-
queryAllByHintText: (matcher: TextMatch, options?: ByHintTextOptions) => QueryAllReturn;
|
|
225
|
-
findByA11yHint: (
|
|
226
|
-
matcher: TextMatch,
|
|
227
|
-
queryOptions?: ByHintTextOptions,
|
|
228
|
-
waitForOptions?: WaitForOptions,
|
|
229
|
-
) => FindReturn;
|
|
230
|
-
findByHintText: (
|
|
231
|
-
matcher: TextMatch,
|
|
232
|
-
queryOptions?: ByHintTextOptions,
|
|
233
|
-
waitForOptions?: WaitForOptions,
|
|
234
|
-
) => FindReturn;
|
|
235
|
-
findAllByA11yHint: (
|
|
236
|
-
matcher: TextMatch,
|
|
237
|
-
queryOptions?: ByHintTextOptions,
|
|
238
|
-
waitForOptions?: WaitForOptions,
|
|
239
|
-
) => FindAllReturn;
|
|
240
|
-
findAllByHintText: (
|
|
241
|
-
matcher: TextMatch,
|
|
242
|
-
queryOptions?: ByHintTextOptions,
|
|
243
|
-
waitForOptions?: WaitForOptions,
|
|
244
|
-
) => FindAllReturn;
|
|
245
|
-
|
|
246
|
-
// Role
|
|
247
|
-
getByRole: (matcher: A11yRole | RegExp, role?: ByRoleOptions) => GetReturn;
|
|
248
|
-
getAllByRole: (matcher: A11yRole | RegExp, options?: ByRoleOptions) => GetAllReturn;
|
|
249
|
-
queryByRole: (matcher: A11yRole | RegExp, options?: ByRoleOptions) => QueryReturn;
|
|
250
|
-
queryAllByRole: (matcher: A11yRole | RegExp, options?: ByRoleOptions) => QueryAllReturn;
|
|
251
|
-
findByRole: (
|
|
252
|
-
matcher: A11yRole | RegExp,
|
|
253
|
-
queryOptions?: ByRoleOptions,
|
|
254
|
-
waitForOptions?: WaitForOptions,
|
|
255
|
-
) => FindReturn;
|
|
256
|
-
findAllByRole: (
|
|
257
|
-
matcher: A11yRole | RegExp,
|
|
258
|
-
queryOptions?: ByRoleOptions,
|
|
259
|
-
waitForOptions?: WaitForOptions,
|
|
260
|
-
) => FindAllReturn;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
interface Thenable {
|
|
264
|
-
then: (resolve: () => any, reject?: () => any) => any;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
type MapPropsFunction = (
|
|
268
|
-
props: { [string]: mixed },
|
|
269
|
-
node: ReactTestRendererJSON,
|
|
270
|
-
) => { [string]: mixed };
|
|
271
|
-
|
|
272
|
-
type DebugOptions = {
|
|
273
|
-
message?: string,
|
|
274
|
-
mapProps?: MapPropsFunction,
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
type Queries = ByTextQueries &
|
|
278
|
-
ByTestIdQueries &
|
|
279
|
-
ByDisplayValueQueries &
|
|
280
|
-
ByPlaceholderTextQueries &
|
|
281
|
-
UnsafeByTypeQueries &
|
|
282
|
-
UnsafeByPropsQueries &
|
|
283
|
-
A11yAPI;
|
|
284
|
-
|
|
285
|
-
type FireEventFunction = (
|
|
286
|
-
element: ReactTestInstance,
|
|
287
|
-
eventName: string,
|
|
288
|
-
...data: Array<any>
|
|
289
|
-
) => any;
|
|
290
|
-
|
|
291
|
-
type FireEventAPI = FireEventFunction & {
|
|
292
|
-
press: (element: ReactTestInstance, ...data: Array<any>) => any,
|
|
293
|
-
changeText: (element: ReactTestInstance, ...data: Array<any>) => any,
|
|
294
|
-
scroll: (element: ReactTestInstance, ...data: Array<any>) => any,
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
declare module '@testing-library/react-native' {
|
|
298
|
-
declare interface RenderResult extends Queries {
|
|
299
|
-
update(nextElement: React.Element<any>): void;
|
|
300
|
-
rerender(nextElement: React.Element<any>): void;
|
|
301
|
-
unmount(nextElement?: React.Element<any>): void;
|
|
302
|
-
toJSON(): ReactTestRendererJSON[] | ReactTestRendererJSON | null;
|
|
303
|
-
debug(options?: DebugOptions): void;
|
|
304
|
-
root: ReactTestInstance;
|
|
305
|
-
UNSAFE_root: ReactTestInstance;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
declare type RenderAPI = RenderResult;
|
|
309
|
-
|
|
310
|
-
declare interface RenderOptions {
|
|
311
|
-
wrapper?: React.ComponentType<any>;
|
|
312
|
-
createNodeMock?: (element: React.Element<any>) => any;
|
|
313
|
-
unstable_validateStringsRenderedWithinText?: boolean;
|
|
314
|
-
unstable_isConcurrent?: boolean;
|
|
315
|
-
unstable_strictMode?: boolean;
|
|
316
|
-
unstable_concurrentUpdatesByDefault?: boolean;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
declare export var render: (
|
|
320
|
-
component: React.Element<any>,
|
|
321
|
-
options?: RenderOptions,
|
|
322
|
-
) => RenderResult;
|
|
323
|
-
|
|
324
|
-
declare export var screen: RenderResult;
|
|
325
|
-
|
|
326
|
-
declare export var cleanup: () => void;
|
|
327
|
-
declare export var fireEvent: FireEventAPI;
|
|
328
|
-
|
|
329
|
-
declare export var waitFor: WaitForFunction;
|
|
330
|
-
|
|
331
|
-
declare type WaitForElementToBeRemovedFunction = <T = any>(
|
|
332
|
-
expectation: () => T,
|
|
333
|
-
options?: WaitForOptions,
|
|
334
|
-
) => Promise<T>;
|
|
335
|
-
|
|
336
|
-
declare export var waitForElementToBeRemoved: WaitForElementToBeRemovedFunction;
|
|
337
|
-
|
|
338
|
-
declare interface Config {
|
|
339
|
-
asyncUtilTimeout: number;
|
|
340
|
-
defaultIncludeHiddenElements: boolean;
|
|
341
|
-
defaultDebugOptions?: $Shape<DebugOptions>;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
declare interface ConfigAliasOptions {
|
|
345
|
-
/** Alias to `defaultIncludeHiddenElements` for RTL compatibility */
|
|
346
|
-
defaultHidden: boolean;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
declare export var configure: (options: $Shape<Config & ConfigAliasOptions>) => void;
|
|
350
|
-
declare export var resetToDefaults: () => void;
|
|
351
|
-
|
|
352
|
-
declare export var act: (callback: () => void) => Thenable;
|
|
353
|
-
declare export var within: (instance: ReactTestInstance) => Queries;
|
|
354
|
-
declare export var getQueriesForElement: (element: ReactTestInstance) => Queries;
|
|
355
|
-
|
|
356
|
-
declare export var getDefaultNormalizer: (normalizerConfig?: NormalizerConfig) => NormalizerFn;
|
|
357
|
-
|
|
358
|
-
declare export var isHiddenFromAccessibility: (element: ReactTestInstance | null) => boolean;
|
|
359
|
-
declare export var isInaccessible: (element: ReactTestInstance | null) => boolean;
|
|
360
|
-
|
|
361
|
-
declare type RenderHookResult<Result, Props> = {
|
|
362
|
-
rerender: (props: Props) => void,
|
|
363
|
-
result: { current: Result },
|
|
364
|
-
unmount: () => void,
|
|
365
|
-
};
|
|
366
|
-
|
|
367
|
-
declare type RenderHookOptions<Props> = {
|
|
368
|
-
initialProps?: Props,
|
|
369
|
-
wrapper?: React.ComponentType<any>,
|
|
370
|
-
};
|
|
371
|
-
|
|
372
|
-
declare type RenderHookFunction = <Result, Props>(
|
|
373
|
-
renderCallback: (props: Props) => Result,
|
|
374
|
-
options?: RenderHookOptions<Props>,
|
|
375
|
-
) => RenderHookResult<Result, Props>;
|
|
376
|
-
|
|
377
|
-
declare export var renderHook: RenderHookFunction;
|
|
378
|
-
}
|