@testing-library/react-native 9.0.0-alpha.0 → 9.2.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 +2 -2
- package/build/act.d.ts +3 -0
- package/build/act.js +2 -1
- package/build/act.js.map +1 -0
- package/build/cleanup.d.ts +5 -0
- package/build/cleanup.js +3 -2
- package/build/cleanup.js.map +1 -0
- package/build/fireEvent.d.ts +8 -0
- package/build/fireEvent.js +2 -1
- package/build/fireEvent.js.map +1 -0
- package/build/flushMicroTasks.d.ts +5 -0
- package/build/flushMicroTasks.js +2 -12
- package/build/flushMicroTasks.js.map +1 -0
- package/build/helpers/a11yAPI.d.ts +66 -0
- package/build/helpers/a11yAPI.js +16 -15
- package/build/helpers/a11yAPI.js.map +1 -0
- package/build/helpers/byDisplayValue.d.ts +6 -0
- package/build/helpers/byDisplayValue.js +2 -1
- package/build/helpers/byDisplayValue.js.map +1 -0
- package/build/helpers/byPlaceholderText.d.ts +6 -0
- package/build/helpers/byPlaceholderText.js +2 -1
- package/build/helpers/byPlaceholderText.js.map +1 -0
- package/build/helpers/byTestId.d.ts +6 -0
- package/build/helpers/byTestId.js +2 -1
- package/build/helpers/byTestId.js.map +1 -0
- package/build/helpers/byText.d.ts +10 -0
- package/build/helpers/byText.js +8 -5
- package/build/helpers/byText.js.map +1 -0
- package/build/helpers/debugDeep.d.ts +5 -0
- package/build/helpers/debugDeep.js +4 -1
- package/build/helpers/debugDeep.js.map +1 -0
- package/build/helpers/debugShallow.d.ts +6 -0
- package/build/helpers/debugShallow.js +4 -7
- package/build/helpers/debugShallow.js.map +1 -0
- package/build/helpers/errors.d.ts +10 -0
- package/build/helpers/errors.js +29 -9
- package/build/helpers/errors.js.map +1 -0
- package/build/helpers/filterNodeByType.d.ts +3 -0
- package/build/helpers/filterNodeByType.js +2 -1
- package/build/helpers/filterNodeByType.js.map +1 -0
- package/build/helpers/findByAPI.d.ts +17 -0
- package/build/helpers/findByAPI.js +2 -1
- package/build/helpers/findByAPI.js.map +1 -0
- package/build/helpers/format.d.ts +3 -0
- package/build/helpers/format.js +4 -3
- package/build/helpers/format.js.map +1 -0
- package/build/helpers/getByAPI.d.ts +31 -0
- package/build/helpers/getByAPI.js +4 -19
- package/build/helpers/getByAPI.js.map +1 -0
- package/build/helpers/makeA11yQuery.d.ts +13 -0
- package/build/helpers/makeA11yQuery.js +2 -1
- package/build/helpers/makeA11yQuery.js.map +1 -0
- package/build/helpers/makeQueries.d.ts +20 -0
- package/build/helpers/makeQueries.js +6 -3
- package/build/helpers/makeQueries.js.map +1 -0
- package/build/helpers/queryByAPI.d.ts +39 -0
- package/build/helpers/queryByAPI.js +3 -8
- package/build/helpers/queryByAPI.js.map +1 -0
- package/build/helpers/timers.d.ts +6 -0
- package/build/helpers/timers.js +9 -6
- package/build/helpers/timers.js.map +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.flow.js +384 -0
- package/build/index.js +2 -1
- package/build/index.js.map +1 -0
- package/build/matches.d.ts +9 -0
- package/build/matches.js +3 -2
- package/build/matches.js.map +1 -0
- package/build/{pure.js.flow → pure.d.ts} +4 -8
- package/build/pure.js +14 -31
- package/build/pure.js.map +1 -0
- package/build/render.d.ts +145 -0
- package/build/render.js +14 -10
- package/build/render.js.map +1 -0
- package/build/renderHook.d.ts +17 -0
- package/build/renderHook.js +57 -0
- package/build/renderHook.js.map +1 -0
- package/build/shallow.d.ts +8 -0
- package/build/shallow.js +3 -9
- package/build/shallow.js.map +1 -0
- package/build/waitFor.d.ts +8 -0
- package/build/waitFor.js +32 -23
- package/build/waitFor.js.map +1 -0
- package/build/waitForElementToBeRemoved.d.ts +2 -0
- package/build/waitForElementToBeRemoved.js +2 -1
- package/build/waitForElementToBeRemoved.js.map +1 -0
- package/build/within.d.ts +127 -0
- package/build/within.js +3 -2
- package/build/within.js.map +1 -0
- package/package.json +25 -15
- package/typings/index.flow.js +384 -0
- package/build/act.js.flow +0 -9
- package/build/cleanup.js.flow +0 -13
- package/build/fireEvent.js.flow +0 -127
- package/build/flushMicroTasks.js.flow +0 -23
- package/build/helpers/a11yAPI.js.flow +0 -241
- package/build/helpers/byDisplayValue.js.flow +0 -66
- package/build/helpers/byPlaceholderText.js.flow +0 -62
- package/build/helpers/byTestId.js.flow +0 -50
- package/build/helpers/byText.js.flow +0 -104
- package/build/helpers/debugDeep.js.flow +0 -16
- package/build/helpers/debugShallow.js.flow +0 -20
- package/build/helpers/errors.js.flow +0 -82
- package/build/helpers/filterNodeByType.js.flow +0 -1
- package/build/helpers/findByAPI.js.flow +0 -76
- package/build/helpers/format.js.flow +0 -10
- package/build/helpers/getByAPI.js.flow +0 -157
- package/build/helpers/makeA11yQuery.js.flow +0 -98
- package/build/helpers/makeQueries.js.flow +0 -165
- package/build/helpers/queryByAPI.js.flow +0 -166
- package/build/helpers/timers.js.flow +0 -88
- package/build/index.js.flow +0 -18
- package/build/matches.js.flow +0 -41
- package/build/render.js.flow +0 -109
- package/build/shallow.js.flow +0 -26
- package/build/types.flow.js +0 -1
- package/build/types.flow.js.flow +0 -59
- package/build/waitFor.js.flow +0 -221
- package/build/waitForElementToBeRemoved.js.flow +0 -42
- package/build/within.js.flow +0 -18
- package/typings/index.d.ts +0 -432
package/build/waitFor.js.flow
DELETED
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
/* globals jest */
|
|
3
|
-
|
|
4
|
-
import * as React from 'react';
|
|
5
|
-
import act from './act';
|
|
6
|
-
import {
|
|
7
|
-
ErrorWithStack,
|
|
8
|
-
throwRemovedFunctionError,
|
|
9
|
-
copyStackTrace,
|
|
10
|
-
} from './helpers/errors';
|
|
11
|
-
import {
|
|
12
|
-
setTimeout,
|
|
13
|
-
clearTimeout,
|
|
14
|
-
setImmediate,
|
|
15
|
-
jestFakeTimersAreEnabled,
|
|
16
|
-
} from './helpers/timers';
|
|
17
|
-
|
|
18
|
-
const DEFAULT_TIMEOUT = 1000;
|
|
19
|
-
const DEFAULT_INTERVAL = 50;
|
|
20
|
-
|
|
21
|
-
function checkReactVersionAtLeast(major: number, minor: number): boolean {
|
|
22
|
-
if (React.version === undefined) return false;
|
|
23
|
-
const [actualMajor, actualMinor] = React.version.split('.').map(Number);
|
|
24
|
-
|
|
25
|
-
return actualMajor > major || (actualMajor === major && actualMinor >= minor);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export type WaitForOptions = {
|
|
29
|
-
timeout?: number,
|
|
30
|
-
interval?: number,
|
|
31
|
-
stackTraceError?: ErrorWithStack,
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
function waitForInternal<T>(
|
|
35
|
-
expectation: () => T,
|
|
36
|
-
{
|
|
37
|
-
timeout = DEFAULT_TIMEOUT,
|
|
38
|
-
interval = DEFAULT_INTERVAL,
|
|
39
|
-
stackTraceError,
|
|
40
|
-
}: WaitForOptions
|
|
41
|
-
): Promise<T> {
|
|
42
|
-
if (typeof expectation !== 'function') {
|
|
43
|
-
throw new TypeError('Received `expectation` arg must be a function');
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// eslint-disable-next-line no-async-promise-executor
|
|
47
|
-
return new Promise(async (resolve, reject) => {
|
|
48
|
-
let lastError, intervalId;
|
|
49
|
-
let finished = false;
|
|
50
|
-
let promiseStatus = 'idle';
|
|
51
|
-
|
|
52
|
-
const overallTimeoutTimer = setTimeout(handleTimeout, timeout);
|
|
53
|
-
|
|
54
|
-
const usingFakeTimers = jestFakeTimersAreEnabled();
|
|
55
|
-
|
|
56
|
-
if (usingFakeTimers) {
|
|
57
|
-
checkExpectation();
|
|
58
|
-
// this is a dangerous rule to disable because it could lead to an
|
|
59
|
-
// infinite loop. However, eslint isn't smart enough to know that we're
|
|
60
|
-
// setting finished inside `onDone` which will be called when we're done
|
|
61
|
-
// waiting or when we've timed out.
|
|
62
|
-
// eslint-disable-next-line no-unmodified-loop-condition
|
|
63
|
-
let fakeTimeRemaining = timeout;
|
|
64
|
-
while (!finished) {
|
|
65
|
-
if (!jestFakeTimersAreEnabled()) {
|
|
66
|
-
const error = new Error(
|
|
67
|
-
`Changed from using fake timers to real timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing to real timers. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830`
|
|
68
|
-
);
|
|
69
|
-
if (stackTraceError) {
|
|
70
|
-
copyStackTrace(error, stackTraceError);
|
|
71
|
-
}
|
|
72
|
-
reject(error);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// when fake timers are used we want to simulate the interval time passing
|
|
77
|
-
if (fakeTimeRemaining <= 0) {
|
|
78
|
-
return;
|
|
79
|
-
} else {
|
|
80
|
-
fakeTimeRemaining -= interval;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// we *could* (maybe should?) use `advanceTimersToNextTimer` but it's
|
|
84
|
-
// possible that could make this loop go on forever if someone is using
|
|
85
|
-
// third party code that's setting up recursive timers so rapidly that
|
|
86
|
-
// the user's timer's don't get a chance to resolve. So we'll advance
|
|
87
|
-
// by an interval instead. (We have a test for this case).
|
|
88
|
-
jest.advanceTimersByTime(interval);
|
|
89
|
-
|
|
90
|
-
// It's really important that checkExpectation is run *before* we flush
|
|
91
|
-
// in-flight promises. To be honest, I'm not sure why, and I can't quite
|
|
92
|
-
// think of a way to reproduce the problem in a test, but I spent
|
|
93
|
-
// an entire day banging my head against a wall on this.
|
|
94
|
-
checkExpectation();
|
|
95
|
-
|
|
96
|
-
// In this rare case, we *need* to wait for in-flight promises
|
|
97
|
-
// to resolve before continuing. We don't need to take advantage
|
|
98
|
-
// of parallelization so we're fine.
|
|
99
|
-
// https://stackoverflow.com/a/59243586/971592
|
|
100
|
-
// eslint-disable-next-line no-await-in-loop
|
|
101
|
-
await new Promise((resolve) => setImmediate(resolve));
|
|
102
|
-
}
|
|
103
|
-
} else {
|
|
104
|
-
intervalId = setInterval(checkRealTimersCallback, interval);
|
|
105
|
-
checkExpectation();
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function onDone(error, result) {
|
|
109
|
-
finished = true;
|
|
110
|
-
clearTimeout(overallTimeoutTimer);
|
|
111
|
-
|
|
112
|
-
if (!usingFakeTimers) {
|
|
113
|
-
clearInterval(intervalId);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (error) {
|
|
117
|
-
reject(error);
|
|
118
|
-
} else {
|
|
119
|
-
// $FlowIgnore[incompatible-return] error and result are mutually exclusive
|
|
120
|
-
resolve(result);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function checkRealTimersCallback() {
|
|
125
|
-
if (jestFakeTimersAreEnabled()) {
|
|
126
|
-
const error = new Error(
|
|
127
|
-
`Changed from using real timers to fake timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing to fake timers. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830`
|
|
128
|
-
);
|
|
129
|
-
if (stackTraceError) {
|
|
130
|
-
copyStackTrace(error, stackTraceError);
|
|
131
|
-
}
|
|
132
|
-
return reject(error);
|
|
133
|
-
} else {
|
|
134
|
-
return checkExpectation();
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function checkExpectation() {
|
|
139
|
-
if (promiseStatus === 'pending') return;
|
|
140
|
-
try {
|
|
141
|
-
const result = expectation();
|
|
142
|
-
|
|
143
|
-
// $FlowIgnore[incompatible-type]
|
|
144
|
-
if (typeof result?.then === 'function') {
|
|
145
|
-
promiseStatus = 'pending';
|
|
146
|
-
// eslint-disable-next-line promise/catch-or-return
|
|
147
|
-
result.then(
|
|
148
|
-
(resolvedValue) => {
|
|
149
|
-
promiseStatus = 'resolved';
|
|
150
|
-
onDone(null, resolvedValue);
|
|
151
|
-
return;
|
|
152
|
-
},
|
|
153
|
-
(rejectedValue) => {
|
|
154
|
-
promiseStatus = 'rejected';
|
|
155
|
-
lastError = rejectedValue;
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
);
|
|
159
|
-
} else {
|
|
160
|
-
onDone(null, result);
|
|
161
|
-
}
|
|
162
|
-
// If `callback` throws, wait for the next mutation, interval, or timeout.
|
|
163
|
-
} catch (error) {
|
|
164
|
-
// Save the most recent callback error to reject the promise with it in the event of a timeout
|
|
165
|
-
lastError = error;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
function handleTimeout() {
|
|
170
|
-
let error;
|
|
171
|
-
if (lastError) {
|
|
172
|
-
error = lastError;
|
|
173
|
-
if (stackTraceError) {
|
|
174
|
-
copyStackTrace(error, stackTraceError);
|
|
175
|
-
}
|
|
176
|
-
} else {
|
|
177
|
-
error = new Error('Timed out in waitFor.');
|
|
178
|
-
if (stackTraceError) {
|
|
179
|
-
copyStackTrace(error, stackTraceError);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
onDone(error, null);
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
export default async function waitFor<T>(
|
|
188
|
-
expectation: () => T,
|
|
189
|
-
options?: WaitForOptions
|
|
190
|
-
): Promise<T> {
|
|
191
|
-
// Being able to display a useful stack trace requires generating it before doing anything async
|
|
192
|
-
const stackTraceError = new ErrorWithStack('STACK_TRACE_ERROR', waitFor);
|
|
193
|
-
const optionsWithStackTrace = { stackTraceError, ...options };
|
|
194
|
-
|
|
195
|
-
if (!checkReactVersionAtLeast(16, 9)) {
|
|
196
|
-
return waitForInternal(expectation, optionsWithStackTrace);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
let result: T;
|
|
200
|
-
|
|
201
|
-
//$FlowFixMe: `act` has incorrect flow typing
|
|
202
|
-
await act(async () => {
|
|
203
|
-
result = await waitForInternal(expectation, optionsWithStackTrace);
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
//$FlowFixMe: either we have result or `waitFor` threw error
|
|
207
|
-
return result;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
export function waitForElement<T>(
|
|
211
|
-
expectation: () => T,
|
|
212
|
-
_timeout: number = 4500,
|
|
213
|
-
_interval: number = 50
|
|
214
|
-
): Promise<T> {
|
|
215
|
-
throwRemovedFunctionError(
|
|
216
|
-
'waitForElement',
|
|
217
|
-
'migration-v2#waitfor-api-changes'
|
|
218
|
-
);
|
|
219
|
-
|
|
220
|
-
return Promise.reject();
|
|
221
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import waitFor, { type WaitForOptions } from './waitFor';
|
|
3
|
-
import { ErrorWithStack } from './helpers/errors';
|
|
4
|
-
|
|
5
|
-
function isRemoved<T>(result: T): boolean {
|
|
6
|
-
return !result || (Array.isArray(result) && !result.length);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export default async function waitForElementToBeRemoved<T>(
|
|
10
|
-
expectation: () => T,
|
|
11
|
-
options?: WaitForOptions
|
|
12
|
-
): Promise<T> {
|
|
13
|
-
// Created here so we get a nice stacktrace
|
|
14
|
-
const timeoutError = new ErrorWithStack(
|
|
15
|
-
'Timed out in waitForElementToBeRemoved.',
|
|
16
|
-
waitForElementToBeRemoved
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
// Elements have to be present initally and then removed.
|
|
20
|
-
const initialElements = expectation();
|
|
21
|
-
if (isRemoved(initialElements)) {
|
|
22
|
-
throw new ErrorWithStack(
|
|
23
|
-
'The element(s) given to waitForElementToBeRemoved are already removed. waitForElementToBeRemoved requires that the element(s) exist(s) before waiting for removal.',
|
|
24
|
-
waitForElementToBeRemoved
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return waitFor(() => {
|
|
29
|
-
let result;
|
|
30
|
-
try {
|
|
31
|
-
result = expectation();
|
|
32
|
-
} catch (error) {
|
|
33
|
-
return initialElements;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (!isRemoved(result)) {
|
|
37
|
-
throw timeoutError;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return initialElements;
|
|
41
|
-
}, options);
|
|
42
|
-
}
|
package/build/within.js.flow
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import { getByAPI, type GetByAPI } from './helpers/getByAPI';
|
|
3
|
-
import { queryByAPI, type QueryByAPI } from './helpers/queryByAPI';
|
|
4
|
-
import { findByAPI, type FindByAPI } from './helpers/findByAPI';
|
|
5
|
-
import { a11yAPI, type A11yAPI } from './helpers/a11yAPI';
|
|
6
|
-
|
|
7
|
-
export function within(
|
|
8
|
-
instance: ReactTestInstance
|
|
9
|
-
): { ...FindByAPI, ...QueryByAPI, ...GetByAPI, ...A11yAPI } {
|
|
10
|
-
return {
|
|
11
|
-
...getByAPI(instance),
|
|
12
|
-
...queryByAPI(instance),
|
|
13
|
-
...findByAPI(instance),
|
|
14
|
-
...a11yAPI(instance),
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const getQueriesForElement = within;
|
package/typings/index.d.ts
DELETED
|
@@ -1,432 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
AccessibilityState,
|
|
4
|
-
// @ts-ignore AccessibilityStates was deprecated in RN0.62 https://reactnative.dev/blog/2020/03/26/version-0.62#breaking-changes
|
|
5
|
-
AccessibilityStates,
|
|
6
|
-
AccessibilityRole,
|
|
7
|
-
} from 'react-native';
|
|
8
|
-
import { ReactTestInstance, ReactTestRendererJSON } from 'react-test-renderer';
|
|
9
|
-
|
|
10
|
-
type GetReturn = ReactTestInstance;
|
|
11
|
-
type GetAllReturn = Array<ReactTestInstance>;
|
|
12
|
-
type QueryReturn = ReactTestInstance | null;
|
|
13
|
-
type QueryAllReturn = Array<ReactTestInstance> | [];
|
|
14
|
-
type FindReturn = Promise<ReactTestInstance>;
|
|
15
|
-
type FindAllReturn = Promise<ReactTestInstance[]>;
|
|
16
|
-
|
|
17
|
-
type TextMatch = string | RegExp;
|
|
18
|
-
|
|
19
|
-
interface GetByAPI {
|
|
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>;
|
|
41
|
-
getAllByPlaceholderText: (
|
|
42
|
-
placeholder: TextMatch,
|
|
43
|
-
options?: TextMatchOptions
|
|
44
|
-
) => Array<ReactTestInstance>;
|
|
45
|
-
getAllByDisplayValue: (
|
|
46
|
-
value: TextMatch,
|
|
47
|
-
options?: TextMatchOptions
|
|
48
|
-
) => Array<ReactTestInstance>;
|
|
49
|
-
|
|
50
|
-
// Unsafe aliases
|
|
51
|
-
UNSAFE_getByType: <P>(type: React.ComponentType<P>) => ReactTestInstance;
|
|
52
|
-
UNSAFE_getAllByType: <P>(
|
|
53
|
-
type: React.ComponentType<P>
|
|
54
|
-
) => Array<ReactTestInstance>;
|
|
55
|
-
UNSAFE_getByProps: (props: Record<string, any>) => ReactTestInstance;
|
|
56
|
-
UNSAFE_getAllByProps: (
|
|
57
|
-
props: Record<string, any>
|
|
58
|
-
) => Array<ReactTestInstance>;
|
|
59
|
-
|
|
60
|
-
// Removed
|
|
61
|
-
/**
|
|
62
|
-
* @deprecated This function has been removed. Please use other queries.
|
|
63
|
-
*/
|
|
64
|
-
getByName: (name: React.ReactType | string) => ReactTestInstance;
|
|
65
|
-
/**
|
|
66
|
-
* @deprecated This function has been renamed to `UNSAFE_getByType`.
|
|
67
|
-
*/
|
|
68
|
-
getByType: <P>(type: React.ComponentType<P>) => ReactTestInstance;
|
|
69
|
-
/**
|
|
70
|
-
* @deprecated This function has been renamed to `UNSAFE_getByProps`.
|
|
71
|
-
*/
|
|
72
|
-
getByProps: (props: Record<string, any>) => ReactTestInstance;
|
|
73
|
-
/**
|
|
74
|
-
* @deprecated This function has been removed. Please use other queries.
|
|
75
|
-
*/
|
|
76
|
-
getAllByName: (name: React.ReactType | string) => Array<ReactTestInstance>;
|
|
77
|
-
/**
|
|
78
|
-
* @deprecated This function has been renamed to `UNSAFE_getAllByType`.
|
|
79
|
-
*/
|
|
80
|
-
getAllByType: <P>(type: React.ComponentType<P>) => Array<ReactTestInstance>;
|
|
81
|
-
/**
|
|
82
|
-
* @deprecated This function has been renamed to `UNSAFE_getAllByProps`.
|
|
83
|
-
*/
|
|
84
|
-
getAllByProps: (props: Record<string, any>) => Array<ReactTestInstance>;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
interface QueryByAPI {
|
|
88
|
-
queryByText: (
|
|
89
|
-
name: TextMatch,
|
|
90
|
-
options?: TextMatchOptions
|
|
91
|
-
) => ReactTestInstance | null;
|
|
92
|
-
queryByPlaceholderText: (
|
|
93
|
-
placeholder: TextMatch,
|
|
94
|
-
options?: TextMatchOptions
|
|
95
|
-
) => ReactTestInstance | null;
|
|
96
|
-
queryByDisplayValue: (
|
|
97
|
-
value: TextMatch,
|
|
98
|
-
options?: TextMatchOptions
|
|
99
|
-
) => ReactTestInstance | null;
|
|
100
|
-
queryByTestId: (testID: TextMatch) => ReactTestInstance | null;
|
|
101
|
-
queryAllByTestId: (testID: TextMatch) => Array<ReactTestInstance> | [];
|
|
102
|
-
queryAllByText: (
|
|
103
|
-
text: TextMatch,
|
|
104
|
-
options?: TextMatchOptions
|
|
105
|
-
) => Array<ReactTestInstance> | [];
|
|
106
|
-
queryAllByPlaceholderText: (
|
|
107
|
-
placeholder: TextMatch,
|
|
108
|
-
options?: TextMatchOptions
|
|
109
|
-
) => Array<ReactTestInstance> | [];
|
|
110
|
-
queryAllByDisplayValue: (
|
|
111
|
-
value: TextMatch,
|
|
112
|
-
options?: TextMatchOptions
|
|
113
|
-
) => Array<ReactTestInstance> | [];
|
|
114
|
-
|
|
115
|
-
// Unsafe aliases
|
|
116
|
-
UNSAFE_queryByType: <P>(
|
|
117
|
-
type: React.ComponentType<P>
|
|
118
|
-
) => ReactTestInstance | null;
|
|
119
|
-
UNSAFE_queryAllByType: <P>(
|
|
120
|
-
type: React.ComponentType<P>
|
|
121
|
-
) => Array<ReactTestInstance> | [];
|
|
122
|
-
UNSAFE_queryByProps: (props: Record<string, any>) => ReactTestInstance | null;
|
|
123
|
-
UNSAFE_queryAllByProps: (
|
|
124
|
-
props: Record<string, any>
|
|
125
|
-
) => Array<ReactTestInstance> | [];
|
|
126
|
-
|
|
127
|
-
// Removed
|
|
128
|
-
/**
|
|
129
|
-
* @deprecated This function has been removed. Please use other queries.
|
|
130
|
-
*/
|
|
131
|
-
queryByName: (name: React.ReactType | string) => ReactTestInstance | null;
|
|
132
|
-
/**
|
|
133
|
-
* @deprecated This function has been renamed to `UNSAFE_queryByType`.
|
|
134
|
-
*/
|
|
135
|
-
queryByType: <P>(type: React.ComponentType<P>) => ReactTestInstance | null;
|
|
136
|
-
/**
|
|
137
|
-
* @deprecated This function has been renamed to `UNSAFE_queryByProps`.
|
|
138
|
-
*/
|
|
139
|
-
queryByProps: (props: Record<string, any>) => ReactTestInstance | null;
|
|
140
|
-
/**
|
|
141
|
-
* @deprecated This function has been removed. Please use other queries.
|
|
142
|
-
*/
|
|
143
|
-
queryAllByName: (
|
|
144
|
-
name: React.ReactType | string
|
|
145
|
-
) => Array<ReactTestInstance> | [];
|
|
146
|
-
/**
|
|
147
|
-
* @deprecated This function has been renamed to `UNSAFE_queryAllByType`.
|
|
148
|
-
*/
|
|
149
|
-
queryAllByType: <P>(
|
|
150
|
-
type: React.ComponentType<P>
|
|
151
|
-
) => Array<ReactTestInstance> | [];
|
|
152
|
-
/**
|
|
153
|
-
* @deprecated This function has been renamed to `UNSAFE_queryAllByProps`.
|
|
154
|
-
*/
|
|
155
|
-
queryAllByProps: (
|
|
156
|
-
props: Record<string, any>
|
|
157
|
-
) => Array<ReactTestInstance> | [];
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
interface FindByAPI {
|
|
161
|
-
findByText: (
|
|
162
|
-
text: TextMatch,
|
|
163
|
-
queryOptions?: TextMatchOptions,
|
|
164
|
-
waitForOptions?: WaitForOptions
|
|
165
|
-
) => FindReturn;
|
|
166
|
-
findByPlaceholderText: (
|
|
167
|
-
placeholder: TextMatch,
|
|
168
|
-
queryOptions?: TextMatchOptions,
|
|
169
|
-
waitForOptions?: WaitForOptions
|
|
170
|
-
) => FindReturn;
|
|
171
|
-
findByDisplayValue: (
|
|
172
|
-
value: TextMatch,
|
|
173
|
-
queryOptions?: TextMatchOptions,
|
|
174
|
-
waitForOptions?: WaitForOptions
|
|
175
|
-
) => FindReturn;
|
|
176
|
-
findByTestId: (
|
|
177
|
-
testID: TextMatch,
|
|
178
|
-
queryOptions?: TextMatchOptions,
|
|
179
|
-
waitForOptions?: WaitForOptions
|
|
180
|
-
) => FindReturn;
|
|
181
|
-
findAllByText: (
|
|
182
|
-
text: TextMatch,
|
|
183
|
-
queryOptions?: TextMatchOptions,
|
|
184
|
-
waitForOptions?: WaitForOptions
|
|
185
|
-
) => FindAllReturn;
|
|
186
|
-
findAllByPlaceholderText: (
|
|
187
|
-
placeholder: TextMatch,
|
|
188
|
-
queryOptions?: TextMatchOptions,
|
|
189
|
-
waitForOptions?: WaitForOptions
|
|
190
|
-
) => FindAllReturn;
|
|
191
|
-
findAllByDisplayValue: (
|
|
192
|
-
value: TextMatch,
|
|
193
|
-
queryOptions?: TextMatchOptions,
|
|
194
|
-
waitForOptions?: WaitForOptions
|
|
195
|
-
) => FindAllReturn;
|
|
196
|
-
findAllByTestId: (
|
|
197
|
-
testID: TextMatch,
|
|
198
|
-
queryOptions?: TextMatchOptions,
|
|
199
|
-
waitForOptions?: WaitForOptions
|
|
200
|
-
) => FindAllReturn;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// Not yet available in DefinitelyTyped
|
|
204
|
-
export type A11yValue = {
|
|
205
|
-
min?: number;
|
|
206
|
-
max?: number;
|
|
207
|
-
now?: number;
|
|
208
|
-
text?: string;
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
type A11yAPI = {
|
|
212
|
-
// Label
|
|
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;
|
|
221
|
-
findByA11yLabel: (
|
|
222
|
-
matcher: TextMatch,
|
|
223
|
-
waitForOptions?: WaitForOptions
|
|
224
|
-
) => FindReturn;
|
|
225
|
-
findByLabelText: (
|
|
226
|
-
matcher: TextMatch,
|
|
227
|
-
waitForOptions?: WaitForOptions
|
|
228
|
-
) => FindReturn;
|
|
229
|
-
findAllByA11yLabel: (
|
|
230
|
-
matcher: TextMatch,
|
|
231
|
-
waitForOptions?: WaitForOptions
|
|
232
|
-
) => FindAllReturn;
|
|
233
|
-
findAllByLabelText: (
|
|
234
|
-
matcher: TextMatch,
|
|
235
|
-
waitForOptions?: WaitForOptions
|
|
236
|
-
) => FindAllReturn;
|
|
237
|
-
|
|
238
|
-
// Hint
|
|
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;
|
|
247
|
-
findByA11yHint: (
|
|
248
|
-
matcher: TextMatch,
|
|
249
|
-
waitForOptions?: WaitForOptions
|
|
250
|
-
) => FindReturn;
|
|
251
|
-
findByHintText: (
|
|
252
|
-
matcher: TextMatch,
|
|
253
|
-
waitForOptions?: WaitForOptions
|
|
254
|
-
) => FindReturn;
|
|
255
|
-
findAllByA11yHint: (
|
|
256
|
-
matcher: TextMatch,
|
|
257
|
-
waitForOptions?: WaitForOptions
|
|
258
|
-
) => FindAllReturn;
|
|
259
|
-
findAllByHintText: (
|
|
260
|
-
matcher: TextMatch,
|
|
261
|
-
waitForOptions?: WaitForOptions
|
|
262
|
-
) => FindAllReturn;
|
|
263
|
-
|
|
264
|
-
// Role
|
|
265
|
-
getByA11yRole: (matcher: AccessibilityRole | RegExp) => GetReturn;
|
|
266
|
-
getByRole: (matcher: AccessibilityRole | RegExp) => GetReturn;
|
|
267
|
-
getAllByA11yRole: (matcher: AccessibilityRole | RegExp) => GetAllReturn;
|
|
268
|
-
getAllByRole: (matcher: AccessibilityRole | RegExp) => GetAllReturn;
|
|
269
|
-
queryByA11yRole: (matcher: AccessibilityRole | RegExp) => QueryReturn;
|
|
270
|
-
queryByRole: (matcher: AccessibilityRole | RegExp) => QueryReturn;
|
|
271
|
-
queryAllByA11yRole: (matcher: AccessibilityRole | RegExp) => QueryAllReturn;
|
|
272
|
-
queryAllByRole: (matcher: AccessibilityRole | RegExp) => QueryAllReturn;
|
|
273
|
-
findByA11yRole: (
|
|
274
|
-
matcher: AccessibilityRole | RegExp,
|
|
275
|
-
waitForOptions?: WaitForOptions
|
|
276
|
-
) => FindReturn;
|
|
277
|
-
findByRole: (
|
|
278
|
-
matcher: AccessibilityRole | RegExp,
|
|
279
|
-
waitForOptions?: WaitForOptions
|
|
280
|
-
) => FindReturn;
|
|
281
|
-
findAllByA11yRole: (
|
|
282
|
-
matcher: AccessibilityRole | RegExp,
|
|
283
|
-
waitForOptions?: WaitForOptions
|
|
284
|
-
) => FindAllReturn;
|
|
285
|
-
findAllByRole: (
|
|
286
|
-
matcher: AccessibilityRole | RegExp,
|
|
287
|
-
waitForOptions?: WaitForOptions
|
|
288
|
-
) => FindAllReturn;
|
|
289
|
-
|
|
290
|
-
// States
|
|
291
|
-
getByA11yStates: (
|
|
292
|
-
matcher: AccessibilityStates | Array<AccessibilityStates>
|
|
293
|
-
) => GetReturn;
|
|
294
|
-
getAllByA11yStates: (
|
|
295
|
-
matcher: AccessibilityStates | Array<AccessibilityStates>
|
|
296
|
-
) => GetAllReturn;
|
|
297
|
-
queryByA11yStates: (
|
|
298
|
-
matcher: AccessibilityStates | Array<AccessibilityStates>
|
|
299
|
-
) => QueryReturn;
|
|
300
|
-
queryAllByA11yStates: (
|
|
301
|
-
matcher: AccessibilityStates | Array<AccessibilityStates>
|
|
302
|
-
) => QueryAllReturn;
|
|
303
|
-
|
|
304
|
-
// State
|
|
305
|
-
getByA11yState: (matcher: AccessibilityState) => GetReturn;
|
|
306
|
-
getAllByA11yState: (matcher: AccessibilityState) => GetAllReturn;
|
|
307
|
-
queryByA11yState: (matcher: AccessibilityState) => QueryReturn;
|
|
308
|
-
queryAllByA11yState: (matcher: AccessibilityState) => QueryAllReturn;
|
|
309
|
-
findByA11yState: (
|
|
310
|
-
matcher: AccessibilityState,
|
|
311
|
-
waitForOptions?: WaitForOptions
|
|
312
|
-
) => FindReturn;
|
|
313
|
-
findAllByA11yState: (
|
|
314
|
-
matcher: AccessibilityState,
|
|
315
|
-
waitForOptions?: WaitForOptions
|
|
316
|
-
) => FindAllReturn;
|
|
317
|
-
|
|
318
|
-
// Value
|
|
319
|
-
getByA11yValue: (matcher: A11yValue) => GetReturn;
|
|
320
|
-
getAllByA11yValue: (matcher: A11yValue) => GetAllReturn;
|
|
321
|
-
queryByA11yValue: (matcher: A11yValue) => QueryReturn;
|
|
322
|
-
queryAllByA11yValue: (matcher: A11yValue) => QueryAllReturn;
|
|
323
|
-
findByA11yValue: (
|
|
324
|
-
matcher: A11yValue,
|
|
325
|
-
waitForOptions?: WaitForOptions
|
|
326
|
-
) => FindReturn;
|
|
327
|
-
findAllByA11yValue: (
|
|
328
|
-
matcher: A11yValue,
|
|
329
|
-
waitForOptions?: WaitForOptions
|
|
330
|
-
) => FindAllReturn;
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
export interface Thenable {
|
|
334
|
-
then: (resolve: () => any, reject?: () => any) => any;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
export interface RenderOptions {
|
|
338
|
-
wrapper?: React.ComponentType<any>;
|
|
339
|
-
createNodeMock?: (element: React.ReactElement<any>) => any;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
type Debug = {
|
|
343
|
-
(message?: string): void;
|
|
344
|
-
shallow: (message?: string) => void;
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
type Queries = GetByAPI & QueryByAPI & FindByAPI & A11yAPI;
|
|
348
|
-
|
|
349
|
-
export interface RenderAPI extends Queries {
|
|
350
|
-
update(nextElement: React.ReactElement<any>): void;
|
|
351
|
-
rerender(nextElement: React.ReactElement<any>): void;
|
|
352
|
-
unmount(nextElement?: React.ReactElement<any>): void;
|
|
353
|
-
toJSON(): ReactTestRendererJSON[] | ReactTestRendererJSON | null;
|
|
354
|
-
debug: Debug;
|
|
355
|
-
container: ReactTestInstance;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
export type FireEventFunction = (
|
|
359
|
-
element: ReactTestInstance,
|
|
360
|
-
eventName: string,
|
|
361
|
-
...data: Array<any>
|
|
362
|
-
) => any;
|
|
363
|
-
|
|
364
|
-
export type FireEventAPI = FireEventFunction & {
|
|
365
|
-
press: (element: ReactTestInstance, ...data: Array<any>) => any;
|
|
366
|
-
changeText: (element: ReactTestInstance, ...data: Array<any>) => any;
|
|
367
|
-
scroll: (element: ReactTestInstance, ...data: Array<any>) => any;
|
|
368
|
-
};
|
|
369
|
-
|
|
370
|
-
export declare const render: (
|
|
371
|
-
component: React.ReactElement<any>,
|
|
372
|
-
options?: RenderOptions
|
|
373
|
-
) => RenderAPI;
|
|
374
|
-
|
|
375
|
-
export declare const cleanup: () => void;
|
|
376
|
-
export declare const fireEvent: FireEventAPI;
|
|
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
|
-
|
|
388
|
-
type WaitForOptions = {
|
|
389
|
-
timeout?: number;
|
|
390
|
-
interval?: number;
|
|
391
|
-
};
|
|
392
|
-
|
|
393
|
-
export type WaitForFunction = <T = any>(
|
|
394
|
-
expectation: () => T,
|
|
395
|
-
options?: WaitForOptions
|
|
396
|
-
) => Promise<T>;
|
|
397
|
-
|
|
398
|
-
export declare const waitFor: WaitForFunction;
|
|
399
|
-
|
|
400
|
-
export type WaitForElementToBeRemovedFunction = <T = any>(
|
|
401
|
-
expectation: () => T,
|
|
402
|
-
options?: WaitForOptions
|
|
403
|
-
) => Promise<T>;
|
|
404
|
-
|
|
405
|
-
export declare const waitForElementToBeRemoved: WaitForElementToBeRemovedFunction;
|
|
406
|
-
|
|
407
|
-
export declare const act: (callback: () => void) => Thenable;
|
|
408
|
-
export declare const within: (instance: ReactTestInstance) => Queries;
|
|
409
|
-
export declare const getQueriesForElement: (
|
|
410
|
-
instance: ReactTestInstance
|
|
411
|
-
) => Queries;
|
|
412
|
-
|
|
413
|
-
export declare const getDefaultNormalizer: (
|
|
414
|
-
normalizerConfig?: NormalizerConfig
|
|
415
|
-
) => NormalizerFn;
|
|
416
|
-
|
|
417
|
-
/**
|
|
418
|
-
* @deprecated This function has been removed. Please use `waitFor` function.
|
|
419
|
-
*/
|
|
420
|
-
export declare const waitForElement: WaitForFunction;
|
|
421
|
-
|
|
422
|
-
/**
|
|
423
|
-
* @deprecated This function has been deprecated and will be removed in the next release.
|
|
424
|
-
*/
|
|
425
|
-
export declare const flushMicrotasksQueue: () => Promise<any>;
|
|
426
|
-
|
|
427
|
-
/**
|
|
428
|
-
* @deprecated This function has been removed.
|
|
429
|
-
*/
|
|
430
|
-
export declare const shallow: <P = {}>(
|
|
431
|
-
instance: ReactTestInstance | React.ReactElement<P>
|
|
432
|
-
) => { output: React.ReactElement<P> };
|