Skip to content

Commit d6265d9

Browse files
suezzoMichał Parkitnythymikee
authored
chore: bump React Native to 0.64 RC (#626)
* chore: bump React Native to 0.64 RC * Snapshot update * Bumped node version to 12 on CI * Removed removed supress_comment syntax from config * codemod types-first * Prettied files after codemod * Added flow types to API returns * don't return null from fireEvent handlers * return ReactTestInstance instead of any * fix render returning any * less anys * less anys * simplify call type * simplify * add Flow to missing files, type debug better Co-authored-by: Michał Parkitny <[email protected]> Co-authored-by: Michał Pierzchała <[email protected]>
1 parent 9a9abde commit d6265d9

23 files changed

+924
-1256
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ aliases:
1212

1313
defaults: &defaults
1414
docker:
15-
- image: circleci/node:10
15+
- image: circleci/node:12
1616
working_directory: ~/react-native-testing-library
1717

1818
jobs:

.flowconfig

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ emoji=true
3232
esproposal.optional_chaining=enable
3333
esproposal.nullish_coalescing=enable
3434

35+
well_formed_exports=true
36+
types_first=true
37+
3538
module.file_ext=.js
3639
module.file_ext=.json
3740
module.file_ext=.ios.js
@@ -41,15 +44,6 @@ munge_underscores=true
4144
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
4245
module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'
4346

44-
suppress_type=$FlowIssue
45-
suppress_type=$FlowFixMe
46-
suppress_type=$FlowFixMeProps
47-
suppress_type=$FlowFixMeState
48-
49-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
50-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
51-
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
52-
5347
[lints]
5448
sketchy-null-number=warn
5549
sketchy-null-mixed=warn

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@
3434
"@callstack/eslint-config": "^10.0.0",
3535
"@release-it/conventional-changelog": "^2.0.0",
3636
"@testing-library/jest-native": "~3.4.3",
37-
"@types/react": "^16.9.34",
37+
"@types/react": "^17.0.0",
3838
"@types/react-native": "^0.63.0",
3939
"@types/react-test-renderer": "^17.0.0",
4040
"babel-jest": "^26.0.1",
4141
"conventional-changelog-cli": "^2.0.11",
4242
"dedent": "^0.7.0",
4343
"eslint": "^7.0.0",
44-
"flow-bin": "^0.122.0",
44+
"flow-bin": "^0.137.0",
4545
"flow-copy-source": "^2.0.9",
4646
"jest": "^26.0.1",
47-
"react": "^16.13.1",
48-
"react-native": "^0.63.0-rc.1",
49-
"react-test-renderer": "^16.13.1",
47+
"react": "^17.0.1",
48+
"react-native": "^0.64.0-rc.1",
49+
"react-test-renderer": "^17.0.1",
5050
"release-it": "^14.0.3",
5151
"strip-ansi": "^6.0.0",
5252
"typescript": "^4.0.2"

src/__tests__/__snapshots__/render.test.js.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,15 @@ exports[`debug: shallow 1`] = `
134134
>
135135
not fresh
136136
</Text>
137-
<Component
137+
<TextInput
138138
allowFontScaling={true}
139139
placeholder=\\"Add custom freshness\\"
140140
rejectResponderTermination={true}
141141
testID=\\"bananaCustomFreshness\\"
142142
underlineColorAndroid=\\"transparent\\"
143143
value=\\"Custom Freshie\\"
144144
/>
145-
<Component
145+
<TextInput
146146
allowFontScaling={true}
147147
placeholder=\\"Who inspected freshness?\\"
148148
rejectResponderTermination={true}
@@ -184,15 +184,15 @@ exports[`debug: shallow with message 1`] = `
184184
>
185185
not fresh
186186
</Text>
187-
<Component
187+
<TextInput
188188
allowFontScaling={true}
189189
placeholder=\\"Add custom freshness\\"
190190
rejectResponderTermination={true}
191191
testID=\\"bananaCustomFreshness\\"
192192
underlineColorAndroid=\\"transparent\\"
193193
value=\\"Custom Freshie\\"
194194
/>
195-
<Component
195+
<TextInput
196196
allowFontScaling={true}
197197
placeholder=\\"Who inspected freshness?\\"
198198
rejectResponderTermination={true}

src/__tests__/auto-cleanup-skip.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @flow
12
import React from 'react';
23
import { View } from 'react-native';
34

src/__tests__/auto-cleanup.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @flow
12
import React from 'react';
23
import { View } from 'react-native';
34
import { render } from '..';

src/act.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// @flow
22
import { act } from 'react-test-renderer';
3+
import type { Thenable } from './types.flow';
34

45
const actMock = (callback: () => void) => {
56
callback();
67
};
78

8-
export default act || actMock;
9+
export default (act || actMock: (callback: () => void) => Thenable);

src/fireEvent.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ const invokeEvent = (
8989
const handler = findEventHandler(element, eventName, callsite);
9090

9191
if (!handler) {
92-
return null;
92+
return;
9393
}
9494

9595
let returnValue;
@@ -104,18 +104,20 @@ const invokeEvent = (
104104
const toEventHandlerName = (eventName: string) =>
105105
`on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`;
106106

107-
const pressHandler = (element: ReactTestInstance) =>
107+
const pressHandler = (element: ReactTestInstance): void =>
108108
invokeEvent(element, 'press', pressHandler);
109-
const changeTextHandler = (element: ReactTestInstance, ...data: Array<any>) =>
110-
invokeEvent(element, 'changeText', changeTextHandler, ...data);
111-
const scrollHandler = (element: ReactTestInstance, ...data: Array<any>) =>
109+
const changeTextHandler = (
110+
element: ReactTestInstance,
111+
...data: Array<any>
112+
): void => invokeEvent(element, 'changeText', changeTextHandler, ...data);
113+
const scrollHandler = (element: ReactTestInstance, ...data: Array<any>): void =>
112114
invokeEvent(element, 'scroll', scrollHandler, ...data);
113115

114116
const fireEvent = (
115117
element: ReactTestInstance,
116118
eventName: string,
117119
...data: Array<any>
118-
) => invokeEvent(element, eventName, fireEvent, ...data);
120+
): void => invokeEvent(element, eventName, fireEvent, ...data);
119121

120122
fireEvent.press = pressHandler;
121123
fireEvent.changeText = changeTextHandler;

src/helpers/a11yAPI.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import makeQuery from './makeQuery';
66
type GetReturn = ReactTestInstance;
77
type GetAllReturn = Array<ReactTestInstance>;
88
type QueryReturn = ReactTestInstance | null;
9-
type QueryAllReturn = Array<ReactTestInstance> | [];
9+
type QueryAllReturn = Array<ReactTestInstance>;
1010
type FindReturn = Promise<GetReturn>;
1111
type FindAllReturn = Promise<GetAllReturn>;
1212

13-
type A11yAPI = {|
13+
export type A11yAPI = {|
1414
// Label
1515
getByA11yLabel: (string | RegExp) => GetReturn,
1616
getByLabelText: (string | RegExp) => GetReturn,
@@ -116,7 +116,7 @@ export function matchObject<T: {}>(prop?: T, matcher: T): boolean {
116116
: false;
117117
}
118118

119-
const a11yAPI = (instance: ReactTestInstance): A11yAPI =>
119+
export const a11yAPI = (instance: ReactTestInstance): A11yAPI =>
120120
({
121121
...makeQuery(
122122
'accessibilityLabel',
@@ -239,5 +239,3 @@ const a11yAPI = (instance: ReactTestInstance): A11yAPI =>
239239
matchObject
240240
)(instance),
241241
}: any);
242-
243-
export default a11yAPI;

src/helpers/debugDeep.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import format from './format';
66
*/
77
export default function debugDeep(
88
instance: ?ReactTestRendererJSON,
9-
message?: any = ''
9+
message?: string
1010
) {
1111
if (message) {
1212
console.log(`${message}\n\n`, format(instance));

0 commit comments

Comments
 (0)