@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.
Files changed (121) hide show
  1. package/README.md +2 -2
  2. package/build/act.d.ts +3 -0
  3. package/build/act.js +2 -1
  4. package/build/act.js.map +1 -0
  5. package/build/cleanup.d.ts +5 -0
  6. package/build/cleanup.js +3 -2
  7. package/build/cleanup.js.map +1 -0
  8. package/build/fireEvent.d.ts +8 -0
  9. package/build/fireEvent.js +2 -1
  10. package/build/fireEvent.js.map +1 -0
  11. package/build/flushMicroTasks.d.ts +5 -0
  12. package/build/flushMicroTasks.js +2 -12
  13. package/build/flushMicroTasks.js.map +1 -0
  14. package/build/helpers/a11yAPI.d.ts +66 -0
  15. package/build/helpers/a11yAPI.js +16 -15
  16. package/build/helpers/a11yAPI.js.map +1 -0
  17. package/build/helpers/byDisplayValue.d.ts +6 -0
  18. package/build/helpers/byDisplayValue.js +2 -1
  19. package/build/helpers/byDisplayValue.js.map +1 -0
  20. package/build/helpers/byPlaceholderText.d.ts +6 -0
  21. package/build/helpers/byPlaceholderText.js +2 -1
  22. package/build/helpers/byPlaceholderText.js.map +1 -0
  23. package/build/helpers/byTestId.d.ts +6 -0
  24. package/build/helpers/byTestId.js +2 -1
  25. package/build/helpers/byTestId.js.map +1 -0
  26. package/build/helpers/byText.d.ts +10 -0
  27. package/build/helpers/byText.js +8 -5
  28. package/build/helpers/byText.js.map +1 -0
  29. package/build/helpers/debugDeep.d.ts +5 -0
  30. package/build/helpers/debugDeep.js +4 -1
  31. package/build/helpers/debugDeep.js.map +1 -0
  32. package/build/helpers/debugShallow.d.ts +6 -0
  33. package/build/helpers/debugShallow.js +4 -7
  34. package/build/helpers/debugShallow.js.map +1 -0
  35. package/build/helpers/errors.d.ts +10 -0
  36. package/build/helpers/errors.js +29 -9
  37. package/build/helpers/errors.js.map +1 -0
  38. package/build/helpers/filterNodeByType.d.ts +3 -0
  39. package/build/helpers/filterNodeByType.js +2 -1
  40. package/build/helpers/filterNodeByType.js.map +1 -0
  41. package/build/helpers/findByAPI.d.ts +17 -0
  42. package/build/helpers/findByAPI.js +2 -1
  43. package/build/helpers/findByAPI.js.map +1 -0
  44. package/build/helpers/format.d.ts +3 -0
  45. package/build/helpers/format.js +4 -3
  46. package/build/helpers/format.js.map +1 -0
  47. package/build/helpers/getByAPI.d.ts +31 -0
  48. package/build/helpers/getByAPI.js +4 -19
  49. package/build/helpers/getByAPI.js.map +1 -0
  50. package/build/helpers/makeA11yQuery.d.ts +13 -0
  51. package/build/helpers/makeA11yQuery.js +2 -1
  52. package/build/helpers/makeA11yQuery.js.map +1 -0
  53. package/build/helpers/makeQueries.d.ts +20 -0
  54. package/build/helpers/makeQueries.js +6 -3
  55. package/build/helpers/makeQueries.js.map +1 -0
  56. package/build/helpers/queryByAPI.d.ts +39 -0
  57. package/build/helpers/queryByAPI.js +3 -8
  58. package/build/helpers/queryByAPI.js.map +1 -0
  59. package/build/helpers/timers.d.ts +6 -0
  60. package/build/helpers/timers.js +9 -6
  61. package/build/helpers/timers.js.map +1 -0
  62. package/build/index.d.ts +1 -0
  63. package/build/index.flow.js +384 -0
  64. package/build/index.js +2 -1
  65. package/build/index.js.map +1 -0
  66. package/build/matches.d.ts +9 -0
  67. package/build/matches.js +3 -2
  68. package/build/matches.js.map +1 -0
  69. package/build/{pure.js.flow → pure.d.ts} +4 -8
  70. package/build/pure.js +14 -31
  71. package/build/pure.js.map +1 -0
  72. package/build/render.d.ts +145 -0
  73. package/build/render.js +14 -10
  74. package/build/render.js.map +1 -0
  75. package/build/renderHook.d.ts +17 -0
  76. package/build/renderHook.js +57 -0
  77. package/build/renderHook.js.map +1 -0
  78. package/build/shallow.d.ts +8 -0
  79. package/build/shallow.js +3 -9
  80. package/build/shallow.js.map +1 -0
  81. package/build/waitFor.d.ts +8 -0
  82. package/build/waitFor.js +32 -23
  83. package/build/waitFor.js.map +1 -0
  84. package/build/waitForElementToBeRemoved.d.ts +2 -0
  85. package/build/waitForElementToBeRemoved.js +2 -1
  86. package/build/waitForElementToBeRemoved.js.map +1 -0
  87. package/build/within.d.ts +127 -0
  88. package/build/within.js +3 -2
  89. package/build/within.js.map +1 -0
  90. package/package.json +25 -15
  91. package/typings/index.flow.js +384 -0
  92. package/build/act.js.flow +0 -9
  93. package/build/cleanup.js.flow +0 -13
  94. package/build/fireEvent.js.flow +0 -127
  95. package/build/flushMicroTasks.js.flow +0 -23
  96. package/build/helpers/a11yAPI.js.flow +0 -241
  97. package/build/helpers/byDisplayValue.js.flow +0 -66
  98. package/build/helpers/byPlaceholderText.js.flow +0 -62
  99. package/build/helpers/byTestId.js.flow +0 -50
  100. package/build/helpers/byText.js.flow +0 -104
  101. package/build/helpers/debugDeep.js.flow +0 -16
  102. package/build/helpers/debugShallow.js.flow +0 -20
  103. package/build/helpers/errors.js.flow +0 -82
  104. package/build/helpers/filterNodeByType.js.flow +0 -1
  105. package/build/helpers/findByAPI.js.flow +0 -76
  106. package/build/helpers/format.js.flow +0 -10
  107. package/build/helpers/getByAPI.js.flow +0 -157
  108. package/build/helpers/makeA11yQuery.js.flow +0 -98
  109. package/build/helpers/makeQueries.js.flow +0 -165
  110. package/build/helpers/queryByAPI.js.flow +0 -166
  111. package/build/helpers/timers.js.flow +0 -88
  112. package/build/index.js.flow +0 -18
  113. package/build/matches.js.flow +0 -41
  114. package/build/render.js.flow +0 -109
  115. package/build/shallow.js.flow +0 -26
  116. package/build/types.flow.js +0 -1
  117. package/build/types.flow.js.flow +0 -59
  118. package/build/waitFor.js.flow +0 -221
  119. package/build/waitForElementToBeRemoved.js.flow +0 -42
  120. package/build/within.js.flow +0 -18
  121. package/typings/index.d.ts +0 -432
@@ -0,0 +1,127 @@
1
+ /// <reference types="react" />
2
+ import type { ReactTestInstance } from 'react-test-renderer';
3
+ export declare function within(instance: ReactTestInstance): {
4
+ getByLabelText: (label: import("./matches").TextMatch) => ReactTestInstance;
5
+ getAllByLabelText: (label: import("./matches").TextMatch) => ReactTestInstance[];
6
+ queryByLabelText: (label: import("./matches").TextMatch) => ReactTestInstance | null;
7
+ queryAllByLabelText: (label: import("./matches").TextMatch) => ReactTestInstance[];
8
+ findByLabelText: (label: import("./matches").TextMatch, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>;
9
+ findAllByLabelText: (label: import("./matches").TextMatch, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
10
+ getByA11yHint: (a11yHint: import("./matches").TextMatch) => ReactTestInstance;
11
+ getByHintText: (a11yHint: import("./matches").TextMatch) => ReactTestInstance;
12
+ getAllByA11yHint: (a11yHint: import("./matches").TextMatch) => ReactTestInstance[];
13
+ getAllByHintText: (a11yHint: import("./matches").TextMatch) => ReactTestInstance[];
14
+ queryByA11yHint: (a11yHint: import("./matches").TextMatch) => ReactTestInstance | null;
15
+ queryByHintText: (a11yHint: import("./matches").TextMatch) => ReactTestInstance | null;
16
+ queryAllByA11yHint: (a11yHint: import("./matches").TextMatch) => ReactTestInstance[];
17
+ queryAllByHintText: (a11yHint: import("./matches").TextMatch) => ReactTestInstance[];
18
+ findByA11yHint: (a11yHint: import("./matches").TextMatch, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>;
19
+ findByHintText: (a11yHint: import("./matches").TextMatch, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>;
20
+ findAllByA11yHint: (a11yHint: import("./matches").TextMatch, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
21
+ findAllByHintText: (a11yHint: import("./matches").TextMatch, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
22
+ getByRole: (role: RegExp | import("react-native").AccessibilityRole) => ReactTestInstance;
23
+ getAllByRole: (role: RegExp | import("react-native").AccessibilityRole) => ReactTestInstance[];
24
+ queryByRole: (role: RegExp | import("react-native").AccessibilityRole) => ReactTestInstance | null;
25
+ queryAllByRole: (role: RegExp | import("react-native").AccessibilityRole) => ReactTestInstance[];
26
+ findByRole: (role: import("react-native").AccessibilityRole, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>;
27
+ findAllByRole: (role: import("react-native").AccessibilityRole, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
28
+ getByA11yStates: (accessibilityStateKey: keyof import("react-native").AccessibilityState | (keyof import("react-native").AccessibilityState)[]) => ReactTestInstance;
29
+ getAllByA11yStates: (accessibilityStateKey: keyof import("react-native").AccessibilityState | (keyof import("react-native").AccessibilityState)[]) => ReactTestInstance[];
30
+ queryByA11yStates: (accessibilityStateKey: keyof import("react-native").AccessibilityState | (keyof import("react-native").AccessibilityState)[]) => ReactTestInstance | null;
31
+ queryAllByA11yStates: (accessibilityStateKey: keyof import("react-native").AccessibilityState | (keyof import("react-native").AccessibilityState)[]) => ReactTestInstance[];
32
+ findByA11yStates: (accessibilityStateKey: keyof import("react-native").AccessibilityState, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>;
33
+ findAllByA11yStates: (accessibilityStateKey: keyof import("react-native").AccessibilityState, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
34
+ getByA11yState: (accessibilityState: import("react-native").AccessibilityState) => ReactTestInstance;
35
+ getAllByA11yState: (accessibilityState: import("react-native").AccessibilityState) => ReactTestInstance[];
36
+ queryByA11yState: (accessibilityState: import("react-native").AccessibilityState) => ReactTestInstance | null;
37
+ queryAllByA11yState: (accessibilityState: import("react-native").AccessibilityState) => ReactTestInstance[];
38
+ findByA11yState: (accessibilityState: import("react-native").AccessibilityState, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>;
39
+ findAllByA11yState: (accessibilityState: import("react-native").AccessibilityState, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
40
+ getByA11yValue: (a11yValue: {
41
+ min?: number | undefined;
42
+ max?: number | undefined;
43
+ now?: number | undefined;
44
+ text?: string | undefined;
45
+ }) => ReactTestInstance;
46
+ getAllByA11yValue: (a11yValue: {
47
+ min?: number | undefined;
48
+ max?: number | undefined;
49
+ now?: number | undefined;
50
+ text?: string | undefined;
51
+ }) => ReactTestInstance[];
52
+ queryByA11yValue: (a11yValue: {
53
+ min?: number | undefined;
54
+ max?: number | undefined;
55
+ now?: number | undefined;
56
+ text?: string | undefined;
57
+ }) => ReactTestInstance | null;
58
+ queryAllByA11yValue: (a11yValue: {
59
+ min?: number | undefined;
60
+ max?: number | undefined;
61
+ now?: number | undefined;
62
+ text?: string | undefined;
63
+ }) => ReactTestInstance[];
64
+ findByA11yValue: (a11yValue: {
65
+ min?: number | undefined;
66
+ max?: number | undefined;
67
+ now?: number | undefined;
68
+ text?: string | undefined;
69
+ }, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>;
70
+ findAllByA11yValue: (a11yValue: {
71
+ min?: number | undefined;
72
+ max?: number | undefined;
73
+ now?: number | undefined;
74
+ text?: string | undefined;
75
+ }, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
76
+ findAllByDisplayValue: (value: import("./matches").TextMatch, queryOptions?: (import("./helpers/byText").TextMatchOptions & import("./waitFor").WaitForOptions) | undefined, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
77
+ findAllByPlaceholder: () => void;
78
+ findAllByPlaceholderText: (placeholder: import("./matches").TextMatch, queryOptions?: (import("./helpers/byText").TextMatchOptions & import("./waitFor").WaitForOptions) | undefined, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
79
+ findAllByTestId: (testId: import("./matches").TextMatch, queryOptions?: (import("./helpers/byText").TextMatchOptions & import("./waitFor").WaitForOptions) | undefined, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
80
+ findAllByText: (text: import("./matches").TextMatch, queryOptions?: (import("./helpers/byText").TextMatchOptions & import("./waitFor").WaitForOptions) | undefined, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
81
+ findByDisplayValue: (value: import("./matches").TextMatch, queryOptions?: (import("./helpers/byText").TextMatchOptions & import("./waitFor").WaitForOptions) | undefined, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>;
82
+ findByPlaceholder: () => void;
83
+ findByPlaceholderText: (placeholder: import("./matches").TextMatch, queryOptions?: (import("./helpers/byText").TextMatchOptions & import("./waitFor").WaitForOptions) | undefined, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>;
84
+ findByTestId: (testId: import("./matches").TextMatch, queryOptions?: (import("./helpers/byText").TextMatchOptions & import("./waitFor").WaitForOptions) | undefined, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>;
85
+ findByText: (text: import("./matches").TextMatch, queryOptions?: (import("./helpers/byText").TextMatchOptions & import("./waitFor").WaitForOptions) | undefined, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>;
86
+ queryByText: (name: import("./matches").TextMatch, queryOptions?: import("./helpers/byText").TextMatchOptions | undefined) => ReactTestInstance | null;
87
+ queryAllByText: (text: import("./matches").TextMatch, queryOptions?: import("./helpers/byText").TextMatchOptions | undefined) => ReactTestInstance[];
88
+ queryByPlaceholderText: (placeholder: import("./matches").TextMatch, queryOptions?: import("./helpers/byText").TextMatchOptions | undefined) => ReactTestInstance | null;
89
+ queryAllByPlaceholderText: (placeholder: import("./matches").TextMatch, queryOptions?: import("./helpers/byText").TextMatchOptions | undefined) => ReactTestInstance[];
90
+ queryByDisplayValue: (value: import("./matches").TextMatch, queryOptions?: import("./helpers/byText").TextMatchOptions | undefined) => ReactTestInstance | null;
91
+ queryAllByDisplayValue: (value: import("./matches").TextMatch, queryOptions?: import("./helpers/byText").TextMatchOptions | undefined) => ReactTestInstance[];
92
+ queryByTestId: (testID: import("./matches").TextMatch) => ReactTestInstance | null;
93
+ queryAllByTestId: (testID: import("./matches").TextMatch) => ReactTestInstance[];
94
+ UNSAFE_queryByType: <P>(type: import("react").ComponentType<P>) => ReactTestInstance | null;
95
+ UNSAFE_queryAllByType: <P_1>(type: import("react").ComponentType<P_1>) => ReactTestInstance[];
96
+ UNSAFE_queryByProps: (props: {
97
+ [key: string]: any;
98
+ }) => ReactTestInstance | null;
99
+ UNSAFE_queryAllByProps: (props: {
100
+ [key: string]: any;
101
+ }) => ReactTestInstance[];
102
+ queryByName: () => void;
103
+ queryByType: () => void;
104
+ queryByProps: () => void;
105
+ queryAllByName: () => void;
106
+ queryAllByType: () => void;
107
+ queryAllByProps: () => void;
108
+ queryByPlaceholder: () => void;
109
+ queryAllByPlaceholder: () => void;
110
+ getByText: (text: import("./matches").TextMatch, queryOptions?: import("./helpers/byText").TextMatchOptions | undefined) => ReactTestInstance;
111
+ getByPlaceholderText: (placeholder: import("./matches").TextMatch, queryOptions?: import("./helpers/byText").TextMatchOptions | undefined) => ReactTestInstance;
112
+ getByDisplayValue: (value: import("./matches").TextMatch, queryOptions?: import("./helpers/byText").TextMatchOptions | undefined) => ReactTestInstance;
113
+ getByTestId: (testID: import("./matches").TextMatch, queryOptions?: import("./helpers/byText").TextMatchOptions | undefined) => ReactTestInstance;
114
+ getAllByTestId: (testID: import("./matches").TextMatch, queryOptions?: import("./helpers/byText").TextMatchOptions | undefined) => ReactTestInstance[];
115
+ getAllByText: (text: import("./matches").TextMatch, queryOptions?: import("./helpers/byText").TextMatchOptions | undefined) => ReactTestInstance[];
116
+ getAllByPlaceholderText: (placeholder: import("./matches").TextMatch, queryOptions?: import("./helpers/byText").TextMatchOptions | undefined) => ReactTestInstance[];
117
+ getAllByDisplayValue: (value: import("./matches").TextMatch, queryOptions?: import("./helpers/byText").TextMatchOptions | undefined) => ReactTestInstance[];
118
+ UNSAFE_getByType: <P_2>(type: import("react").ComponentType<P_2>) => ReactTestInstance;
119
+ UNSAFE_getAllByType: <P_3>(type: import("react").ComponentType<P_3>) => ReactTestInstance[];
120
+ UNSAFE_getByProps: (props: {
121
+ [key: string]: any;
122
+ }) => ReactTestInstance;
123
+ UNSAFE_getAllByProps: (props: {
124
+ [key: string]: any;
125
+ }) => ReactTestInstance[];
126
+ };
127
+ export declare const getQueriesForElement: typeof within;
package/build/within.js CHANGED
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.within = within;
7
6
  exports.getQueriesForElement = void 0;
7
+ exports.within = within;
8
8
 
9
9
  var _getByAPI = require("./helpers/getByAPI");
10
10
 
@@ -23,4 +23,5 @@ function within(instance) {
23
23
  }
24
24
 
25
25
  const getQueriesForElement = within;
26
- exports.getQueriesForElement = getQueriesForElement;
26
+ exports.getQueriesForElement = getQueriesForElement;
27
+ //# sourceMappingURL=within.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/within.ts"],"names":["within","instance","getQueriesForElement"],"mappings":";;;;;;;;AACA;;AACA;;AACA;;AACA;;AAEO,SAASA,MAAT,CAAgBC,QAAhB,EAA6C;AAClD,SAAO,EACL,GAAG,wBAASA,QAAT,CADE;AAEL,OAAG,4BAAWA,QAAX,CAFE;AAGL,OAAG,0BAAUA,QAAV,CAHE;AAIL,OAAG,sBAAQA,QAAR;AAJE,GAAP;AAMD;;AAEM,MAAMC,oBAAoB,GAAGF,MAA7B","sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { getByAPI } from './helpers/getByAPI';\nimport { queryByAPI } from './helpers/queryByAPI';\nimport { findByAPI } from './helpers/findByAPI';\nimport { a11yAPI } from './helpers/a11yAPI';\n\nexport function within(instance: ReactTestInstance) {\n return {\n ...getByAPI(instance),\n ...queryByAPI(instance),\n ...findByAPI(instance),\n ...a11yAPI(instance),\n };\n}\n\nexport const getQueriesForElement = within;\n"],"file":"within.js"}
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@testing-library/react-native",
3
- "version": "9.0.0-alpha.0",
3
+ "version": "9.2.0",
4
4
  "description": "Simple and complete React Native testing utilities that encourage good testing practices.",
5
5
  "main": "build/index.js",
6
- "typings": "./typings/index.d.ts",
6
+ "types": "build/index.d.ts",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "https://www.github.com/callstack/react-native-testing-library.git"
@@ -21,7 +21,7 @@
21
21
  "files": [
22
22
  "build/",
23
23
  "jest-preset/",
24
- "typings/index.d.ts",
24
+ "typings/index.flow.js",
25
25
  "pure.js",
26
26
  "dont-cleanup-after-each.js"
27
27
  ],
@@ -29,18 +29,23 @@
29
29
  "@babel/cli": "^7.8.4",
30
30
  "@babel/core": "^7.9.0",
31
31
  "@babel/plugin-proposal-class-properties": "^7.8.3",
32
+ "@babel/plugin-transform-flow-strip-types": "^7.16.0",
32
33
  "@babel/preset-env": "^7.9.6",
33
34
  "@babel/preset-flow": "^7.9.0",
34
35
  "@babel/preset-react": "^7.9.4",
35
- "@callstack/eslint-config": "^10.0.0",
36
+ "@babel/preset-typescript": "^7.16.0",
37
+ "@callstack/eslint-config": "^11.0.0",
36
38
  "@release-it/conventional-changelog": "^2.0.0",
37
39
  "@testing-library/jest-native": "~4.0.2",
40
+ "@types/jest": "^27.0.0",
38
41
  "@types/react": "^17.0.0",
39
- "@types/react-native": "^0.65.7",
42
+ "@types/react-native": "^0.66.6",
40
43
  "@types/react-test-renderer": "^17.0.0",
41
44
  "babel-jest": "^27.0.0",
42
45
  "conventional-changelog-cli": "^2.0.11",
46
+ "cp-cli": "^2.0.0",
43
47
  "dedent": "^0.7.0",
48
+ "del-cli": "^3.0.1",
44
49
  "eslint": "^7.0.0",
45
50
  "flow-bin": "^0.141.0",
46
51
  "flow-copy-source": "^2.0.9",
@@ -61,25 +66,30 @@
61
66
  "react-test-renderer": ">=16.0.0"
62
67
  },
63
68
  "scripts": {
69
+ "clean": "del build",
64
70
  "test": "jest",
65
- "flow-check": "flow check",
66
- "typescript-check": "tsc --noEmit --skipLibCheck --jsx react ./typings/__tests__/*",
71
+ "typecheck": "tsc",
72
+ "flow": "flow",
73
+ "copy-flowtypes": "cp typings/index.flow.js build",
67
74
  "lint": "eslint src --cache",
68
75
  "release": "release-it",
69
- "prepublish": "yarn build && yarn copy-flowtypes",
70
- "copy-flowtypes": "flow-copy-source --ignore __tests__/*.js src build",
71
- "build": "rm -rf build; babel src --out-dir build --ignore 'src/__tests__/*'"
76
+ "prepublish": "yarn build",
77
+ "build:js": "babel src --out-dir build --extensions \".js,.ts,.jsx,.tsx\" --source-maps --ignore \"**/__tests__/**\"",
78
+ "build:js:watch": "yarn build:js --watch",
79
+ "build:ts": "tsc --build tsconfig.release.json",
80
+ "build:ts:watch": "yarn build:ts --watch --preserveWatchOutput",
81
+ "build": "yarn clean && yarn build:js && yarn build:ts && yarn copy-flowtypes",
82
+ "prepare": "yarn build"
72
83
  },
73
84
  "jest": {
74
85
  "preset": "../jest-preset",
75
- "moduleFileExtensions": [
76
- "js",
77
- "json"
78
- ],
79
86
  "rootDir": "./src",
80
87
  "testPathIgnorePatterns": [
81
88
  "timerUtils"
82
89
  ],
83
- "testTimeout": 30000
90
+ "testTimeout": 30000,
91
+ "transformIgnorePatterns": [
92
+ "/node_modules/(?!(@react-native|react-native)/).*/"
93
+ ]
84
94
  }
85
95
  }
@@ -0,0 +1,384 @@
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 TextMatch = string | RegExp;
12
+
13
+ declare type NormalizerFn = (textToNormalize: string) => string;
14
+ declare type NormalizerConfig = {
15
+ trim?: boolean,
16
+ collapseWhitespace?: boolean,
17
+ };
18
+ declare type TextMatchOptions = {
19
+ exact?: boolean,
20
+ normalizer?: NormalizerFn,
21
+ };
22
+ declare type A11yRole =
23
+ | 'none'
24
+ | 'button'
25
+ | 'link'
26
+ | 'search'
27
+ | 'image'
28
+ | 'keyboardkey'
29
+ | 'text'
30
+ | 'adjustable'
31
+ | 'imagebutton'
32
+ | 'header'
33
+ | 'summary'
34
+ | 'alert'
35
+ | 'checkbox'
36
+ | 'combobox'
37
+ | 'menu'
38
+ | 'menubar'
39
+ | 'menuitem'
40
+ | 'progressbar'
41
+ | 'radio'
42
+ | 'radiogroup'
43
+ | 'scrollbar'
44
+ | 'spinbutton'
45
+ | 'switch'
46
+ | 'tab'
47
+ | 'tablist'
48
+ | 'timer'
49
+ | 'toolbar';
50
+
51
+ declare type A11yState = {|
52
+ disabled?: boolean,
53
+ selected?: boolean,
54
+ checked?: boolean | 'mixed',
55
+ busy?: boolean,
56
+ expanded?: boolean,
57
+ |};
58
+
59
+ declare type A11yStates =
60
+ | 'disabled'
61
+ | 'selected'
62
+ | 'checked'
63
+ | 'unchecked'
64
+ | 'busy'
65
+ | 'expanded'
66
+ | 'collapsed'
67
+ | 'hasPopup';
68
+
69
+ declare type A11yValue = {
70
+ min?: number,
71
+ max?: number,
72
+ now?: number,
73
+ text?: string,
74
+ };
75
+
76
+ interface GetByAPI {
77
+ getByText: (text: TextMatch, options?: TextMatchOptions) => ReactTestInstance;
78
+ getByPlaceholderText: (
79
+ placeholder: TextMatch,
80
+ options?: TextMatchOptions
81
+ ) => ReactTestInstance;
82
+ getByDisplayValue: (
83
+ value: TextMatch,
84
+ options?: TextMatchOptions
85
+ ) => ReactTestInstance;
86
+ getByTestId: (
87
+ testID: TextMatch,
88
+ options?: TextMatchOptions
89
+ ) => ReactTestInstance;
90
+ getAllByTestId: (
91
+ testID: TextMatch,
92
+ options?: TextMatchOptions
93
+ ) => Array<ReactTestInstance>;
94
+ getAllByText: (
95
+ text: TextMatch,
96
+ options?: TextMatchOptions
97
+ ) => Array<ReactTestInstance>;
98
+ getAllByPlaceholderText: (
99
+ placeholder: TextMatch,
100
+ options?: TextMatchOptions
101
+ ) => Array<ReactTestInstance>;
102
+ getAllByDisplayValue: (
103
+ value: TextMatch,
104
+ options?: TextMatchOptions
105
+ ) => Array<ReactTestInstance>;
106
+
107
+ // Unsafe aliases
108
+ UNSAFE_getByType: <P>(type: React.ComponentType<P>) => ReactTestInstance;
109
+ UNSAFE_getAllByType: <P>(
110
+ type: React.ComponentType<P>
111
+ ) => Array<ReactTestInstance>;
112
+ UNSAFE_getByProps: (props: { [string]: any }) => ReactTestInstance;
113
+ UNSAFE_getAllByProps: (props: { [string]: any }) => Array<ReactTestInstance>;
114
+ }
115
+
116
+ interface QueryByAPI {
117
+ queryByText: (
118
+ name: TextMatch,
119
+ options?: TextMatchOptions
120
+ ) => ReactTestInstance | null;
121
+ queryByPlaceholderText: (
122
+ placeholder: TextMatch,
123
+ options?: TextMatchOptions
124
+ ) => ReactTestInstance | null;
125
+ queryByDisplayValue: (
126
+ value: TextMatch,
127
+ options?: TextMatchOptions
128
+ ) => ReactTestInstance | null;
129
+ queryByTestId: (testID: TextMatch) => ReactTestInstance | null;
130
+ queryAllByTestId: (testID: TextMatch) => Array<ReactTestInstance> | [];
131
+ queryAllByText: (
132
+ text: TextMatch,
133
+ options?: TextMatchOptions
134
+ ) => Array<ReactTestInstance> | [];
135
+ queryAllByPlaceholderText: (
136
+ placeholder: TextMatch,
137
+ options?: TextMatchOptions
138
+ ) => Array<ReactTestInstance> | [];
139
+ queryAllByDisplayValue: (
140
+ value: TextMatch,
141
+ options?: TextMatchOptions
142
+ ) => Array<ReactTestInstance> | [];
143
+
144
+ // Unsafe aliases
145
+ UNSAFE_queryByType: <P>(
146
+ type: React.ComponentType<P>
147
+ ) => ReactTestInstance | null;
148
+ UNSAFE_queryAllByType: <P>(
149
+ type: React.ComponentType<P>
150
+ ) => Array<ReactTestInstance> | [];
151
+ UNSAFE_queryByProps: (props: { [string]: any }) => ReactTestInstance | null;
152
+ UNSAFE_queryAllByProps: (props: { [string]: any }) =>
153
+ | Array<ReactTestInstance>
154
+ | [];
155
+ }
156
+
157
+ type WaitForOptions = {
158
+ timeout?: number,
159
+ interval?: number,
160
+ onTimeout?: (error: mixed) => Error,
161
+ };
162
+ type WaitForFunction = <T = any>(
163
+ expectation: () => T,
164
+ options?: WaitForOptions
165
+ ) => Promise<T>;
166
+
167
+ interface FindByAPI {
168
+ findByText: (
169
+ text: TextMatch,
170
+ queryOptions?: TextMatchOptions,
171
+ waitForOptions?: WaitForOptions
172
+ ) => FindReturn;
173
+ findByPlaceholderText: (
174
+ placeholder: TextMatch,
175
+ queryOptions?: TextMatchOptions,
176
+ waitForOptions?: WaitForOptions
177
+ ) => FindReturn;
178
+ findByDisplayValue: (
179
+ value: TextMatch,
180
+ queryOptions?: TextMatchOptions,
181
+ waitForOptions?: WaitForOptions
182
+ ) => FindReturn;
183
+ findByTestId: (
184
+ testID: TextMatch,
185
+ queryOptions?: TextMatchOptions,
186
+ waitForOptions?: WaitForOptions
187
+ ) => FindReturn;
188
+ findAllByText: (
189
+ text: TextMatch,
190
+ queryOptions?: TextMatchOptions,
191
+ waitForOptions?: WaitForOptions
192
+ ) => FindAllReturn;
193
+ findAllByPlaceholderText: (
194
+ placeholder: TextMatch,
195
+ queryOptions?: TextMatchOptions,
196
+ waitForOptions?: WaitForOptions
197
+ ) => FindAllReturn;
198
+ findAllByDisplayValue: (
199
+ value: TextMatch,
200
+ queryOptions?: TextMatchOptions,
201
+ waitForOptions?: WaitForOptions
202
+ ) => FindAllReturn;
203
+ findAllByTestId: (
204
+ testID: TextMatch,
205
+ queryOptions?: TextMatchOptions,
206
+ waitForOptions?: WaitForOptions
207
+ ) => FindAllReturn;
208
+ }
209
+
210
+ interface A11yAPI {
211
+ // Label
212
+ getByLabelText: (matcher: TextMatch) => GetReturn;
213
+ getAllByLabelText: (matcher: TextMatch) => GetAllReturn;
214
+ queryByLabelText: (matcher: TextMatch) => QueryReturn;
215
+ queryAllByLabelText: (matcher: TextMatch) => QueryAllReturn;
216
+ findByLabelText: (
217
+ matcher: TextMatch,
218
+ waitForOptions?: WaitForOptions
219
+ ) => FindReturn;
220
+ findAllByLabelText: (
221
+ matcher: TextMatch,
222
+ waitForOptions?: WaitForOptions
223
+ ) => FindAllReturn;
224
+
225
+ // Hint
226
+ getByA11yHint: (matcher: TextMatch) => GetReturn;
227
+ getByHintText: (matcher: TextMatch) => GetReturn;
228
+ getAllByA11yHint: (matcher: TextMatch) => GetAllReturn;
229
+ getAllByHintText: (matcher: TextMatch) => GetAllReturn;
230
+ queryByA11yHint: (matcher: TextMatch) => QueryReturn;
231
+ queryByHintText: (matcher: TextMatch) => QueryReturn;
232
+ queryAllByA11yHint: (matcher: TextMatch) => QueryAllReturn;
233
+ queryAllByHintText: (matcher: TextMatch) => QueryAllReturn;
234
+ findByA11yHint: (
235
+ matcher: TextMatch,
236
+ waitForOptions?: WaitForOptions
237
+ ) => FindReturn;
238
+ findByHintText: (
239
+ matcher: TextMatch,
240
+ waitForOptions?: WaitForOptions
241
+ ) => FindReturn;
242
+ findAllByA11yHint: (
243
+ matcher: TextMatch,
244
+ waitForOptions?: WaitForOptions
245
+ ) => FindAllReturn;
246
+ findAllByHintText: (
247
+ matcher: TextMatch,
248
+ waitForOptions?: WaitForOptions
249
+ ) => FindAllReturn;
250
+
251
+ // Role
252
+ getByRole: (matcher: A11yRole | RegExp) => GetReturn;
253
+ getAllByRole: (matcher: A11yRole | RegExp) => GetAllReturn;
254
+ queryByRole: (matcher: A11yRole | RegExp) => QueryReturn;
255
+ queryAllByRole: (matcher: A11yRole | RegExp) => QueryAllReturn;
256
+ findByRole: (
257
+ matcher: A11yRole | RegExp,
258
+ waitForOptions?: WaitForOptions
259
+ ) => FindReturn;
260
+ findAllByRole: (
261
+ matcher: A11yRole | RegExp,
262
+ waitForOptions?: WaitForOptions
263
+ ) => FindAllReturn;
264
+
265
+ // States
266
+ getByA11yStates: (matcher: A11yStates | Array<A11yStates>) => GetReturn;
267
+ getAllByA11yStates: (matcher: A11yStates | Array<A11yStates>) => GetAllReturn;
268
+ queryByA11yStates: (matcher: A11yStates | Array<A11yStates>) => QueryReturn;
269
+ queryAllByA11yStates: (
270
+ matcher: A11yStates | Array<A11yStates>
271
+ ) => QueryAllReturn;
272
+
273
+ // State
274
+ getByA11yState: (matcher: A11yStates) => GetReturn;
275
+ getAllByA11yState: (matcher: A11yStates) => GetAllReturn;
276
+ queryByA11yState: (matcher: A11yStates) => QueryReturn;
277
+ queryAllByA11yState: (matcher: A11yStates) => QueryAllReturn;
278
+ findByA11yState: (
279
+ matcher: A11yStates,
280
+ waitForOptions?: WaitForOptions
281
+ ) => FindReturn;
282
+ findAllByA11yState: (
283
+ matcher: A11yStates,
284
+ waitForOptions?: WaitForOptions
285
+ ) => FindAllReturn;
286
+
287
+ // Value
288
+ getByA11yValue: (matcher: A11yValue) => GetReturn;
289
+ getAllByA11yValue: (matcher: A11yValue) => GetAllReturn;
290
+ queryByA11yValue: (matcher: A11yValue) => QueryReturn;
291
+ queryAllByA11yValue: (matcher: A11yValue) => QueryAllReturn;
292
+ findByA11yValue: (
293
+ matcher: A11yValue,
294
+ waitForOptions?: WaitForOptions
295
+ ) => FindReturn;
296
+ findAllByA11yValue: (
297
+ matcher: A11yValue,
298
+ waitForOptions?: WaitForOptions
299
+ ) => FindAllReturn;
300
+ }
301
+
302
+ interface Thenable {
303
+ then: (resolve: () => any, reject?: () => any) => any;
304
+ }
305
+
306
+ interface RenderOptions {
307
+ wrapper?: React.ComponentType<any>;
308
+ createNodeMock?: (element: React.Element<any>) => any;
309
+ }
310
+
311
+ type Debug = {
312
+ (message?: string): void,
313
+ shallow: (message?: string) => void,
314
+ };
315
+
316
+ type Queries = GetByAPI & QueryByAPI & FindByAPI & A11yAPI;
317
+
318
+ interface RenderAPI extends Queries {
319
+ update(nextElement: React.Element<any>): void;
320
+ rerender(nextElement: React.Element<any>): void;
321
+ unmount(nextElement?: React.Element<any>): void;
322
+ toJSON(): ReactTestRendererJSON[] | ReactTestRendererJSON | null;
323
+ debug: Debug;
324
+ container: ReactTestInstance;
325
+ }
326
+
327
+ type FireEventFunction = (
328
+ element: ReactTestInstance,
329
+ eventName: string,
330
+ ...data: Array<any>
331
+ ) => any;
332
+
333
+ type FireEventAPI = FireEventFunction & {
334
+ press: (element: ReactTestInstance, ...data: Array<any>) => any,
335
+ changeText: (element: ReactTestInstance, ...data: Array<any>) => any,
336
+ scroll: (element: ReactTestInstance, ...data: Array<any>) => any,
337
+ };
338
+
339
+ type RenderHookResult<Result, Props> = {
340
+ rerender: (props: Props) => void,
341
+ result: { current: Result },
342
+ unmount: () => void,
343
+ };
344
+
345
+ type RenderHookOptions<Props> = {
346
+ initialProps?: Props,
347
+ wrapper?: React.ComponentType<any>,
348
+ };
349
+
350
+ declare module '@testing-library/react-native' {
351
+ declare export var render: (
352
+ component: React.Element<any>,
353
+ options?: RenderOptions
354
+ ) => RenderAPI;
355
+
356
+ declare export var cleanup: () => void;
357
+ declare export var fireEvent: FireEventAPI;
358
+
359
+ declare export var waitFor: WaitForFunction;
360
+
361
+ declare type WaitForElementToBeRemovedFunction = <T = any>(
362
+ expectation: () => T,
363
+ options?: WaitForOptions
364
+ ) => Promise<T>;
365
+
366
+ declare export var waitForElementToBeRemoved: WaitForElementToBeRemovedFunction;
367
+
368
+ declare export var act: (callback: () => void) => Thenable;
369
+ declare export var within: (instance: ReactTestInstance) => Queries;
370
+ declare export var getQueriesForElement: (
371
+ instance: ReactTestInstance
372
+ ) => Queries;
373
+
374
+ declare export var getDefaultNormalizer: (
375
+ normalizerConfig?: NormalizerConfig
376
+ ) => NormalizerFn;
377
+
378
+ declare type RenderHookFunction = <Result, Props>(
379
+ renderCallback: (props: Props) => Result,
380
+ options?: RenderHookOptions<Props>
381
+ ) => RenderHookResult<Result, Props>;
382
+
383
+ declare export var renderHook: RenderHookFunction;
384
+ }
package/build/act.js.flow DELETED
@@ -1,9 +0,0 @@
1
- // @flow
2
- import { act } from 'react-test-renderer';
3
- import type { Thenable } from './types.flow';
4
-
5
- const actMock = (callback: () => void) => {
6
- callback();
7
- };
8
-
9
- export default (act || actMock: (callback: () => void) => Thenable);
@@ -1,13 +0,0 @@
1
- // @flow
2
- let cleanupQueue = new Set();
3
-
4
- export default function cleanup() {
5
- cleanupQueue.forEach((fn) => fn());
6
- cleanupQueue.clear();
7
- }
8
-
9
- export function addToCleanupQueue(
10
- fn: (nextElement?: React$Element<any>) => void
11
- ) {
12
- cleanupQueue.add(fn);
13
- }