@testing-library/react-native 7.1.0 → 8.0.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.
Files changed (52) hide show
  1. package/README.md +24 -4
  2. package/build/act.js.flow +2 -1
  3. package/build/fireEvent.js +24 -17
  4. package/build/fireEvent.js.flow +36 -28
  5. package/build/flushMicroTasks.js +3 -1
  6. package/build/flushMicroTasks.js.flow +1 -0
  7. package/build/helpers/a11yAPI.js +9 -10
  8. package/build/helpers/a11yAPI.js.flow +10 -12
  9. package/build/helpers/byDisplayValue.js +48 -0
  10. package/build/helpers/byDisplayValue.js.flow +56 -0
  11. package/build/helpers/byPlaceholderText.js +47 -0
  12. package/build/helpers/byPlaceholderText.js.flow +54 -0
  13. package/build/helpers/byTestId.js +36 -0
  14. package/build/helpers/byTestId.js.flow +46 -0
  15. package/build/helpers/byText.js +94 -0
  16. package/build/helpers/byText.js.flow +88 -0
  17. package/build/helpers/debugDeep.js +1 -1
  18. package/build/helpers/debugDeep.js.flow +1 -1
  19. package/build/helpers/debugShallow.js.flow +1 -1
  20. package/build/helpers/errors.js +6 -0
  21. package/build/helpers/errors.js.flow +10 -3
  22. package/build/helpers/filterNodeByType.js +10 -0
  23. package/build/helpers/filterNodeByType.js.flow +1 -0
  24. package/build/helpers/findByAPI.js +14 -46
  25. package/build/helpers/findByAPI.js.flow +43 -58
  26. package/build/helpers/format.js.flow +1 -1
  27. package/build/helpers/getByAPI.js +16 -184
  28. package/build/helpers/getByAPI.js.flow +52 -204
  29. package/build/helpers/{makeQuery.js → makeA11yQuery.js} +2 -2
  30. package/build/helpers/{makeQuery.js.flow → makeA11yQuery.js.flow} +5 -3
  31. package/build/helpers/makeQueries.js +78 -0
  32. package/build/helpers/makeQueries.js.flow +114 -0
  33. package/build/helpers/queryByAPI.js +16 -88
  34. package/build/helpers/queryByAPI.js.flow +57 -90
  35. package/build/helpers/timers.js +77 -0
  36. package/build/helpers/timers.js.flow +88 -0
  37. package/build/index.js +1 -0
  38. package/build/render.js +11 -4
  39. package/build/render.js.flow +32 -8
  40. package/build/shallow.js.flow +1 -1
  41. package/build/types.flow.js.flow +4 -0
  42. package/build/waitFor.js +148 -19
  43. package/build/waitFor.js.flow +159 -18
  44. package/build/waitForElementToBeRemoved.js +3 -1
  45. package/build/waitForElementToBeRemoved.js.flow +3 -2
  46. package/build/within.js +2 -4
  47. package/build/within.js.flow +7 -5
  48. package/jest-preset/index.js +10 -0
  49. package/jest-preset/restore-promise.js +1 -0
  50. package/jest-preset/save-promise.js +1 -0
  51. package/package.json +20 -15
  52. package/typings/index.d.ts +13 -4
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.queryByTestId = exports.queryAllByTestId = exports.getByTestId = exports.getAllByTestId = exports.findByTestId = exports.findAllByTestId = void 0;
7
+
8
+ var _makeQueries = require("./makeQueries");
9
+
10
+ const getNodeByTestId = (node, testID) => {
11
+ return typeof testID === 'string' ? testID === node.props.testID : testID.test(node.props.testID);
12
+ };
13
+
14
+ const queryAllByTestId = instance => function queryAllByTestIdFn(testId) {
15
+ const results = instance.findAll(node => getNodeByTestId(node, testId)).filter(element => typeof element.type === 'string');
16
+ return results;
17
+ };
18
+
19
+ exports.queryAllByTestId = queryAllByTestId;
20
+
21
+ const getMultipleError = testId => `Found multiple elements with testID: ${String(testId)}`;
22
+
23
+ const getMissingError = testId => `Unable to find an element with testID: ${String(testId)}`;
24
+
25
+ const {
26
+ getBy: getByTestId,
27
+ getAllBy: getAllByTestId,
28
+ queryBy: queryByTestId,
29
+ findBy: findByTestId,
30
+ findAllBy: findAllByTestId
31
+ } = (0, _makeQueries.makeQueries)(queryAllByTestId, getMissingError, getMultipleError);
32
+ exports.findAllByTestId = findAllByTestId;
33
+ exports.findByTestId = findByTestId;
34
+ exports.queryByTestId = queryByTestId;
35
+ exports.getAllByTestId = getAllByTestId;
36
+ exports.getByTestId = getByTestId;
@@ -0,0 +1,46 @@
1
+ // @flow
2
+ import { makeQueries } from './makeQueries';
3
+ import type { Queries } from './makeQueries';
4
+
5
+ const getNodeByTestId = (node, testID) => {
6
+ return typeof testID === 'string'
7
+ ? testID === node.props.testID
8
+ : testID.test(node.props.testID);
9
+ };
10
+
11
+ const queryAllByTestId = (
12
+ instance: ReactTestInstance
13
+ ): ((testId: string | RegExp) => Array<ReactTestInstance>) =>
14
+ function queryAllByTestIdFn(testId) {
15
+ const results = instance
16
+ .findAll((node) => getNodeByTestId(node, testId))
17
+ .filter((element) => typeof element.type === 'string');
18
+
19
+ return results;
20
+ };
21
+
22
+ const getMultipleError = (testId) =>
23
+ `Found multiple elements with testID: ${String(testId)}`;
24
+ const getMissingError = (testId) =>
25
+ `Unable to find an element with testID: ${String(testId)}`;
26
+
27
+ const {
28
+ getBy: getByTestId,
29
+ getAllBy: getAllByTestId,
30
+ queryBy: queryByTestId,
31
+ findBy: findByTestId,
32
+ findAllBy: findAllByTestId,
33
+ }: Queries<string | RegExp> = makeQueries(
34
+ queryAllByTestId,
35
+ getMissingError,
36
+ getMultipleError
37
+ );
38
+
39
+ export {
40
+ findAllByTestId,
41
+ findByTestId,
42
+ getAllByTestId,
43
+ getByTestId,
44
+ queryAllByTestId,
45
+ queryByTestId,
46
+ };
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.queryByText = exports.queryAllByText = exports.getByText = exports.getAllByText = exports.findByText = exports.findAllByText = void 0;
7
+
8
+ var React = _interopRequireWildcard(require("react"));
9
+
10
+ var _makeQueries = require("./makeQueries");
11
+
12
+ var _filterNodeByType = require("./filterNodeByType");
13
+
14
+ var _errors = require("./errors");
15
+
16
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
17
+
18
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
+
20
+ const getChildrenAsText = (children, TextComponent, textContent = []) => {
21
+ React.Children.forEach(children, child => {
22
+ var _child$props;
23
+
24
+ if (typeof child === 'string') {
25
+ textContent.push(child);
26
+ return;
27
+ }
28
+
29
+ if (typeof child === 'number') {
30
+ textContent.push(child.toString());
31
+ return;
32
+ }
33
+
34
+ if (child !== null && child !== void 0 && (_child$props = child.props) !== null && _child$props !== void 0 && _child$props.children) {
35
+ // Bail on traversing text children down the tree if current node (child)
36
+ // has no text. In such situations, react-test-renderer will traverse down
37
+ // this tree in a separate call and run this query again. As a result, the
38
+ // query will match the deepest text node that matches requested text.
39
+ if ((0, _filterNodeByType.filterNodeByType)(child, TextComponent) && textContent.length === 0) {
40
+ return;
41
+ }
42
+
43
+ getChildrenAsText(child.props.children, TextComponent, textContent);
44
+ }
45
+ });
46
+ return textContent;
47
+ };
48
+
49
+ const getNodeByText = (node, text) => {
50
+ try {
51
+ const {
52
+ Text
53
+ } = require('react-native');
54
+
55
+ const isTextComponent = (0, _filterNodeByType.filterNodeByType)(node, Text);
56
+
57
+ if (isTextComponent) {
58
+ const textChildren = getChildrenAsText(node.props.children, Text);
59
+
60
+ if (textChildren) {
61
+ const textToTest = textChildren.join('');
62
+ return typeof text === 'string' ? text === textToTest : text.test(textToTest);
63
+ }
64
+ }
65
+
66
+ return false;
67
+ } catch (error) {
68
+ throw (0, _errors.createLibraryNotSupportedError)(error);
69
+ }
70
+ };
71
+
72
+ const queryAllByText = instance => function queryAllByTextFn(text) {
73
+ const results = instance.findAll(node => getNodeByText(node, text));
74
+ return results;
75
+ };
76
+
77
+ exports.queryAllByText = queryAllByText;
78
+
79
+ const getMultipleError = text => `Found multiple elements with text: ${String(text)}`;
80
+
81
+ const getMissingError = text => `Unable to find an element with text: ${String(text)}`;
82
+
83
+ const {
84
+ getBy: getByText,
85
+ getAllBy: getAllByText,
86
+ queryBy: queryByText,
87
+ findBy: findByText,
88
+ findAllBy: findAllByText
89
+ } = (0, _makeQueries.makeQueries)(queryAllByText, getMissingError, getMultipleError);
90
+ exports.findAllByText = findAllByText;
91
+ exports.findByText = findByText;
92
+ exports.queryByText = queryByText;
93
+ exports.getAllByText = getAllByText;
94
+ exports.getByText = getByText;
@@ -0,0 +1,88 @@
1
+ // @flow
2
+ import * as React from 'react';
3
+ import { makeQueries } from './makeQueries';
4
+ import type { Queries } from './makeQueries';
5
+ import { filterNodeByType } from './filterNodeByType';
6
+ import { createLibraryNotSupportedError } from './errors';
7
+
8
+ const getChildrenAsText = (children, TextComponent, textContent = []) => {
9
+ React.Children.forEach(children, (child) => {
10
+ if (typeof child === 'string') {
11
+ textContent.push(child);
12
+ return;
13
+ }
14
+
15
+ if (typeof child === 'number') {
16
+ textContent.push(child.toString());
17
+ return;
18
+ }
19
+
20
+ if (child?.props?.children) {
21
+ // Bail on traversing text children down the tree if current node (child)
22
+ // has no text. In such situations, react-test-renderer will traverse down
23
+ // this tree in a separate call and run this query again. As a result, the
24
+ // query will match the deepest text node that matches requested text.
25
+ if (filterNodeByType(child, TextComponent) && textContent.length === 0) {
26
+ return;
27
+ }
28
+
29
+ getChildrenAsText(child.props.children, TextComponent, textContent);
30
+ }
31
+ });
32
+
33
+ return textContent;
34
+ };
35
+
36
+ const getNodeByText = (node, text: string | RegExp) => {
37
+ try {
38
+ const { Text } = require('react-native');
39
+ const isTextComponent = filterNodeByType(node, Text);
40
+ if (isTextComponent) {
41
+ const textChildren = getChildrenAsText(node.props.children, Text);
42
+ if (textChildren) {
43
+ const textToTest = textChildren.join('');
44
+ return typeof text === 'string'
45
+ ? text === textToTest
46
+ : text.test(textToTest);
47
+ }
48
+ }
49
+ return false;
50
+ } catch (error) {
51
+ throw createLibraryNotSupportedError(error);
52
+ }
53
+ };
54
+
55
+ const queryAllByText = (
56
+ instance: ReactTestInstance
57
+ ): ((text: string | RegExp) => Array<ReactTestInstance>) =>
58
+ function queryAllByTextFn(text) {
59
+ const results = instance.findAll((node) => getNodeByText(node, text));
60
+
61
+ return results;
62
+ };
63
+
64
+ const getMultipleError = (text: string | RegExp) =>
65
+ `Found multiple elements with text: ${String(text)}`;
66
+ const getMissingError = (text: string | RegExp) =>
67
+ `Unable to find an element with text: ${String(text)}`;
68
+
69
+ const {
70
+ getBy: getByText,
71
+ getAllBy: getAllByText,
72
+ queryBy: queryByText,
73
+ findBy: findByText,
74
+ findAllBy: findAllByText,
75
+ }: Queries<string | RegExp> = makeQueries(
76
+ queryAllByText,
77
+ getMissingError,
78
+ getMultipleError
79
+ );
80
+
81
+ export {
82
+ findAllByText,
83
+ findByText,
84
+ getAllByText,
85
+ getByText,
86
+ queryAllByText,
87
+ queryByText,
88
+ };
@@ -12,7 +12,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
12
12
  /**
13
13
  * Log pretty-printed deep test component instance
14
14
  */
15
- function debugDeep(instance, message = '') {
15
+ function debugDeep(instance, message) {
16
16
  if (message) {
17
17
  console.log(`${message}\n\n`, (0, _format.default)(instance));
18
18
  } else {
@@ -6,7 +6,7 @@ import format from './format';
6
6
  */
7
7
  export default function debugDeep(
8
8
  instance: ?ReactTestRendererJSON,
9
- message?: any = ''
9
+ message?: string
10
10
  ) {
11
11
  if (message) {
12
12
  console.log(`${message}\n\n`, format(instance));
@@ -8,7 +8,7 @@ import format from './format';
8
8
  */
9
9
  export default function debugShallow(
10
10
  instance: ReactTestInstance | React.Element<any>,
11
- message?: any
11
+ message?: string
12
12
  ) {
13
13
  const { output } = shallowInternal(instance);
14
14
 
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.copyStackTrace = copyStackTrace;
6
7
  exports.printDeprecationWarning = printDeprecationWarning;
7
8
  exports.throwRemovedFunctionError = throwRemovedFunctionError;
8
9
  exports.throwRenamedFunctionError = throwRenamedFunctionError;
@@ -53,6 +54,11 @@ const createQueryByError = (error, callsite) => {
53
54
  };
54
55
 
55
56
  exports.createQueryByError = createQueryByError;
57
+
58
+ function copyStackTrace(target, stackTraceSource) {
59
+ target.stack = stackTraceSource.stack.replace(stackTraceSource.message, target.message);
60
+ }
61
+
56
62
  const warned = {};
57
63
 
58
64
  function printDeprecationWarning(functionName) {
@@ -10,7 +10,7 @@ export class ErrorWithStack extends Error {
10
10
  }
11
11
  }
12
12
 
13
- export const createLibraryNotSupportedError = (error: Error) =>
13
+ export const createLibraryNotSupportedError = (error: Error): Error =>
14
14
  new Error(
15
15
  `Currently the only supported library to search by text is "react-native".\n\n${error.message}`
16
16
  );
@@ -19,7 +19,7 @@ export const prepareErrorMessage = (
19
19
  error: Error,
20
20
  name: ?string,
21
21
  value: ?mixed
22
- ) => {
22
+ ): string => {
23
23
  // Strip info about custom predicate
24
24
  let errorMessage = error.message.replace(
25
25
  / matching custom predicate[^]*/gm,
@@ -32,13 +32,20 @@ export const prepareErrorMessage = (
32
32
  return errorMessage;
33
33
  };
34
34
 
35
- export const createQueryByError = (error: Error, callsite: Function) => {
35
+ export const createQueryByError = (error: Error, callsite: Function): null => {
36
36
  if (error.message.includes('No instances found')) {
37
37
  return null;
38
38
  }
39
39
  throw new ErrorWithStack(error.message, callsite);
40
40
  };
41
41
 
42
+ export function copyStackTrace(target: Error, stackTraceSource: Error) {
43
+ target.stack = stackTraceSource.stack.replace(
44
+ stackTraceSource.message,
45
+ target.message
46
+ );
47
+ }
48
+
42
49
  const warned = {};
43
50
 
44
51
  export function printDeprecationWarning(functionName: string) {
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.filterNodeByType = void 0;
7
+
8
+ const filterNodeByType = (node, type) => node.type === type;
9
+
10
+ exports.filterNodeByType = filterNodeByType;
@@ -0,0 +1 @@
1
+ export const filterNodeByType = (node, type) => node.type === type;
@@ -3,59 +3,27 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.findByAPI = exports.findAllByDisplayValue = exports.findByDisplayValue = exports.findAllByPlaceholderText = exports.findByPlaceholderText = exports.findAllByText = exports.findByText = exports.findAllByTestId = exports.findByTestId = void 0;
6
+ exports.findByAPI = void 0;
7
7
 
8
- var _waitFor = _interopRequireDefault(require("../waitFor"));
8
+ var _byTestId = require("./byTestId");
9
9
 
10
- var _getByAPI = require("./getByAPI");
10
+ var _byText = require("./byText");
11
11
 
12
- var _errors = require("./errors");
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- const makeFindQuery = (instance, getQuery, text, waitForOptions) => (0, _waitFor.default)(() => getQuery(instance)(text), waitForOptions);
17
-
18
- const findByTestId = instance => (testId, waitForOptions = {}) => makeFindQuery(instance, _getByAPI.getByTestId, testId, waitForOptions);
19
-
20
- exports.findByTestId = findByTestId;
21
-
22
- const findAllByTestId = instance => (testId, waitForOptions = {}) => makeFindQuery(instance, _getByAPI.getAllByTestId, testId, waitForOptions);
23
-
24
- exports.findAllByTestId = findAllByTestId;
25
-
26
- const findByText = instance => (text, waitForOptions = {}) => makeFindQuery(instance, _getByAPI.getByText, text, waitForOptions);
27
-
28
- exports.findByText = findByText;
12
+ var _byPlaceholderText = require("./byPlaceholderText");
29
13
 
30
- const findAllByText = instance => (text, waitForOptions = {}) => makeFindQuery(instance, _getByAPI.getAllByText, text, waitForOptions);
14
+ var _byDisplayValue = require("./byDisplayValue");
31
15
 
32
- exports.findAllByText = findAllByText;
33
-
34
- const findByPlaceholderText = instance => (placeholder, waitForOptions = {}) => makeFindQuery(instance, _getByAPI.getByPlaceholderText, placeholder, waitForOptions);
35
-
36
- exports.findByPlaceholderText = findByPlaceholderText;
37
-
38
- const findAllByPlaceholderText = instance => (placeholder, waitForOptions = {}) => makeFindQuery(instance, _getByAPI.getAllByPlaceholderText, placeholder, waitForOptions);
39
-
40
- exports.findAllByPlaceholderText = findAllByPlaceholderText;
41
-
42
- const findByDisplayValue = instance => (value, waitForOptions = {}) => makeFindQuery(instance, _getByAPI.getByDisplayValue, value, waitForOptions);
43
-
44
- exports.findByDisplayValue = findByDisplayValue;
45
-
46
- const findAllByDisplayValue = instance => (value, waitForOptions = {}) => makeFindQuery(instance, _getByAPI.getAllByDisplayValue, value, waitForOptions);
47
-
48
- exports.findAllByDisplayValue = findAllByDisplayValue;
16
+ var _errors = require("./errors");
49
17
 
50
18
  const findByAPI = instance => ({
51
- findByTestId: findByTestId(instance),
52
- findByText: findByText(instance),
53
- findByPlaceholderText: findByPlaceholderText(instance),
54
- findByDisplayValue: findByDisplayValue(instance),
55
- findAllByTestId: findAllByTestId(instance),
56
- findAllByText: findAllByText(instance),
57
- findAllByPlaceholderText: findAllByPlaceholderText(instance),
58
- findAllByDisplayValue: findAllByDisplayValue(instance),
19
+ findByTestId: (0, _byTestId.findByTestId)(instance),
20
+ findByText: (0, _byText.findByText)(instance),
21
+ findByPlaceholderText: (0, _byPlaceholderText.findByPlaceholderText)(instance),
22
+ findByDisplayValue: (0, _byDisplayValue.findByDisplayValue)(instance),
23
+ findAllByTestId: (0, _byTestId.findAllByTestId)(instance),
24
+ findAllByText: (0, _byText.findAllByText)(instance),
25
+ findAllByPlaceholderText: (0, _byPlaceholderText.findAllByPlaceholderText)(instance),
26
+ findAllByDisplayValue: (0, _byDisplayValue.findAllByDisplayValue)(instance),
59
27
  // Renamed
60
28
  findByPlaceholder: () => (0, _errors.throwRenamedFunctionError)('findByPlaceholder', 'findByPlaceholderText'),
61
29
  findAllByPlaceholder: () => (0, _errors.throwRenamedFunctionError)('findAllByPlaceholder', 'findAllByPlaceholderText')
@@ -1,67 +1,52 @@
1
1
  // @flow
2
- import waitFor from '../waitFor';
3
2
  import type { WaitForOptions } from '../waitFor';
3
+ import { findAllByTestId, findByTestId } from './byTestId';
4
+ import { findAllByText, findByText } from './byText';
4
5
  import {
5
- getByTestId,
6
- getAllByTestId,
7
- getByText,
8
- getAllByText,
9
- getByPlaceholderText,
10
- getAllByPlaceholderText,
11
- getByDisplayValue,
12
- getAllByDisplayValue,
13
- } from './getByAPI';
6
+ findAllByPlaceholderText,
7
+ findByPlaceholderText,
8
+ } from './byPlaceholderText';
9
+ import { findAllByDisplayValue, findByDisplayValue } from './byDisplayValue';
14
10
  import { throwRenamedFunctionError } from './errors';
15
11
 
16
- const makeFindQuery = <Text, Result>(
17
- instance: ReactTestInstance,
18
- getQuery: (instance: ReactTestInstance) => (text: Text) => Result,
19
- text: Text,
20
- waitForOptions: WaitForOptions
21
- ): Promise<Result> => waitFor(() => getQuery(instance)(text), waitForOptions);
12
+ export type FindByAPI = {|
13
+ findAllByDisplayValue: (
14
+ value: string | RegExp,
15
+ waitForOptions?: WaitForOptions
16
+ ) => Promise<Array<ReactTestInstance>>,
17
+ findAllByPlaceholder: () => void,
18
+ findAllByPlaceholderText: (
19
+ placeholder: string | RegExp,
20
+ waitForOptions?: WaitForOptions
21
+ ) => Promise<Array<ReactTestInstance>>,
22
+ findAllByTestId: (
23
+ testId: string | RegExp,
24
+ waitForOptions?: WaitForOptions
25
+ ) => Promise<Array<ReactTestInstance>>,
26
+ findAllByText: (
27
+ text: string | RegExp,
28
+ waitForOptions?: WaitForOptions
29
+ ) => Promise<Array<ReactTestInstance>>,
30
+ findByDisplayValue: (
31
+ value: string | RegExp,
32
+ waitForOptions?: WaitForOptions
33
+ ) => Promise<ReactTestInstance>,
34
+ findByPlaceholder: () => void,
35
+ findByPlaceholderText: (
36
+ placeholder: string | RegExp,
37
+ waitForOptions?: WaitForOptions
38
+ ) => Promise<ReactTestInstance>,
39
+ findByTestId: (
40
+ testId: string | RegExp,
41
+ waitForOptions?: WaitForOptions
42
+ ) => Promise<ReactTestInstance>,
43
+ findByText: (
44
+ text: string | RegExp,
45
+ waitForOptions?: WaitForOptions
46
+ ) => Promise<ReactTestInstance>,
47
+ |};
22
48
 
23
- export const findByTestId = (instance: ReactTestInstance) => (
24
- testId: string | RegExp,
25
- waitForOptions: WaitForOptions = {}
26
- ) => makeFindQuery(instance, getByTestId, testId, waitForOptions);
27
-
28
- export const findAllByTestId = (instance: ReactTestInstance) => (
29
- testId: string | RegExp,
30
- waitForOptions: WaitForOptions = {}
31
- ) => makeFindQuery(instance, getAllByTestId, testId, waitForOptions);
32
-
33
- export const findByText = (instance: ReactTestInstance) => (
34
- text: string | RegExp,
35
- waitForOptions: WaitForOptions = {}
36
- ) => makeFindQuery(instance, getByText, text, waitForOptions);
37
-
38
- export const findAllByText = (instance: ReactTestInstance) => (
39
- text: string | RegExp,
40
- waitForOptions: WaitForOptions = {}
41
- ) => makeFindQuery(instance, getAllByText, text, waitForOptions);
42
-
43
- export const findByPlaceholderText = (instance: ReactTestInstance) => (
44
- placeholder: string | RegExp,
45
- waitForOptions: WaitForOptions = {}
46
- ) => makeFindQuery(instance, getByPlaceholderText, placeholder, waitForOptions);
47
-
48
- export const findAllByPlaceholderText = (instance: ReactTestInstance) => (
49
- placeholder: string | RegExp,
50
- waitForOptions: WaitForOptions = {}
51
- ) =>
52
- makeFindQuery(instance, getAllByPlaceholderText, placeholder, waitForOptions);
53
-
54
- export const findByDisplayValue = (instance: ReactTestInstance) => (
55
- value: string | RegExp,
56
- waitForOptions: WaitForOptions = {}
57
- ) => makeFindQuery(instance, getByDisplayValue, value, waitForOptions);
58
-
59
- export const findAllByDisplayValue = (instance: ReactTestInstance) => (
60
- value: string | RegExp,
61
- waitForOptions: WaitForOptions = {}
62
- ) => makeFindQuery(instance, getAllByDisplayValue, value, waitForOptions);
63
-
64
- export const findByAPI = (instance: ReactTestInstance) => ({
49
+ export const findByAPI = (instance: ReactTestInstance): FindByAPI => ({
65
50
  findByTestId: findByTestId(instance),
66
51
  findByText: findByText(instance),
67
52
  findByPlaceholderText: findByPlaceholderText(instance),
@@ -1,7 +1,7 @@
1
1
  // @flow
2
2
  import prettyFormat, { plugins } from 'pretty-format';
3
3
 
4
- const format = (input: ?ReactTestRendererJSON) =>
4
+ const format = (input: ?ReactTestRendererJSON): typeof prettyFormat =>
5
5
  prettyFormat(input, {
6
6
  plugins: [plugins.ReactTestComponent, plugins.ReactElement],
7
7
  highlight: true,