Skip to content

Commit f248ba1

Browse files
cpojerfacebook-github-bot
authored andcommitted
Upgrade to Jest 25
Summary: This diff upgrades Jest to the latest version which fixes a bunch of issues with snapshots (therefore allowing me to enable the Pressable-test again). Note that this also affects Metro and various other tooling as they all depend on packages like `jest-worker`, `jest-haste-map` etc. Breaking changes: https://github.com/facebook/jest/blob/master/CHANGELOG.md This diff increases node_modules by 3 MiB, primarily because it causes more duplicates of `source-map` (0.8 MiB for each copy) and packages like `chalk` 3.x (vs 2.x). The base install was 15 MiB bigger and I reduced it to this size by playing around with various manual yarn.lock optimizations. However, D21085929 reduces node_modules by 11 MiB and the Babel upgrade reduced node_modules by 13 MiB. I will subsequently work on reducing the size through other packages as well and I'm working with the Jest folks to get rid of superfluous TypeScript stuff for Jest 26. Other changes in this diff: * Fixed Pressable-test * Blackhole node-notifier: It's large and we don't need it, and also the license may be problematic, see: jestjs/jest#8918 * Updated jest-junit (not a Jest package) but blackholed it internally because it is only used for open source CI. * Updated some API calls we use from Jest to account for breaking changes * Made two absolutely egrigious changes to existing product code tests to make them still pass as our match of async/await, fake timers and then/promise using `setImmediate` is tripping up `regenerator` with `Generator is already run` errors in Jest 25. These tests should probably be rewritten. * Locked everything to the same `resolve` version that we were already using, otherwise it was somehow pulling in 1.16 even though nothing internally uses it. Changelog: [General] Update Jest Reviewed By: rickhanlonii Differential Revision: D21064825 fbshipit-source-id: d0011a51355089456718edd84ea0af21fd923a58
1 parent 7cc791b commit f248ba1

File tree

7 files changed

+1363
-832
lines changed

7 files changed

+1363
-832
lines changed

Libraries/Components/ActivityIndicator/__tests__/__snapshots__/ActivityIndicator-test.js.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ exports[`<ActivityIndicator /> should render as expected: should deep render whe
3434
`;
3535

3636
exports[`<ActivityIndicator /> should render as expected: should shallow render as <ActivityIndicator /> when mocked 1`] = `
37-
<ForwardRef(ActivityIndicator)
37+
<ActivityIndicator
3838
animating={true}
3939
color="#0000ff"
4040
hidesWhenStopped={true}
@@ -43,7 +43,7 @@ exports[`<ActivityIndicator /> should render as expected: should shallow render
4343
`;
4444

4545
exports[`<ActivityIndicator /> should render as expected: should shallow render as <ActivityIndicator /> when not mocked 1`] = `
46-
<ForwardRef(ActivityIndicator)
46+
<ActivityIndicator
4747
animating={true}
4848
color="#0000ff"
4949
hidesWhenStopped={true}

Libraries/Components/Pressable/__tests__/Pressable-test.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ import View from '../../View/View';
1818
import {expectRendersMatchingSnapshot} from '../../../Utilities/ReactNativeTestTools';
1919

2020
describe('<Pressable />', () => {
21-
/* eslint-disable jest/no-disabled-tests */
22-
// TODO(cpojer): Reenable this test, see T64907347.
23-
xit('should render as expected', () => {
21+
it('should render as expected', () => {
2422
expectRendersMatchingSnapshot(
2523
'Pressable',
2624
() => (
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`<Pressable /> should render as expected: should deep render when mocked (please verify output manually) 1`] = `
4+
<View
5+
accessible={true}
6+
focusable={true}
7+
onBlur={[Function]}
8+
onClick={[Function]}
9+
onFocus={[Function]}
10+
onResponderGrant={[Function]}
11+
onResponderMove={[Function]}
12+
onResponderRelease={[Function]}
13+
onResponderTerminate={[Function]}
14+
onResponderTerminationRequest={[Function]}
15+
onStartShouldSetResponder={[Function]}
16+
>
17+
<View />
18+
</View>
19+
`;
20+
21+
exports[`<Pressable /> should render as expected: should deep render when not mocked (please verify output manually) 1`] = `
22+
<View
23+
accessible={true}
24+
focusable={true}
25+
onBlur={[Function]}
26+
onClick={[Function]}
27+
onFocus={[Function]}
28+
onResponderGrant={[Function]}
29+
onResponderMove={[Function]}
30+
onResponderRelease={[Function]}
31+
onResponderTerminate={[Function]}
32+
onResponderTerminationRequest={[Function]}
33+
onStartShouldSetResponder={[Function]}
34+
>
35+
<View />
36+
</View>
37+
`;
38+
39+
exports[`<Pressable /> should render as expected: should shallow render as <Pressable /> when mocked 1`] = `
40+
<Memo(Pressable)>
41+
<View />
42+
</Memo(Pressable)>
43+
`;
44+
45+
exports[`<Pressable /> should render as expected: should shallow render as <Pressable /> when not mocked 1`] = `
46+
<Memo(Pressable)>
47+
<View />
48+
</Memo(Pressable)>
49+
`;

Libraries/Components/ScrollView/__tests__/__snapshots__/ScrollView-test.js.snap

+4-4
Original file line numberDiff line numberDiff line change
@@ -71,21 +71,21 @@ exports[`<ScrollView /> should render as expected: should deep render when not m
7171
`;
7272

7373
exports[`<ScrollView /> should render as expected: should shallow render as <ScrollView /> when mocked 1`] = `
74-
<ForwardRef(ScrollView)>
74+
<ScrollView>
7575
<View>
7676
<Text>
7777
Hello World!
7878
</Text>
7979
</View>
80-
</ForwardRef(ScrollView)>
80+
</ScrollView>
8181
`;
8282

8383
exports[`<ScrollView /> should render as expected: should shallow render as <ScrollView /> when not mocked 1`] = `
84-
<ForwardRef(ScrollView)>
84+
<ScrollView>
8585
<View>
8686
<Text>
8787
Hello World!
8888
</Text>
8989
</View>
90-
</ForwardRef(ScrollView)>
90+
</ScrollView>
9191
`;

Libraries/Image/__tests__/__snapshots__/Image-test.js.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ exports[`<Image /> should render as <RCTImageView> when not mocked 1`] = `
3131
`;
3232
3333
exports[`<Image /> should shallow render as <ForwardRef(Image)> when not mocked 1`] = `
34-
<ForwardRef(Image)
34+
<Image
3535
source={
3636
Object {
3737
"uri": "foo-bar.jpg",

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
"metro-react-native-babel-transformer": "0.59.0",
103103
"metro-source-map": "0.59.0",
104104
"nullthrows": "^1.1.1",
105-
"pretty-format": "^24.9.0",
105+
"pretty-format": "^25.4.0",
106106
"promise": "^8.0.3",
107107
"prop-types": "^15.7.2",
108108
"react-devtools-core": "^4.6.0",
@@ -140,8 +140,8 @@
140140
"eslint-plugin-relay": "1.7.0",
141141
"flow-bin": "^0.122.0",
142142
"flow-remove-types": "1.2.3",
143-
"jest": "^24.9.0",
144-
"jest-junit": "^6.3.0",
143+
"jest": "^25.4.0",
144+
"jest-junit": "^10.0.0",
145145
"jscodeshift": "^0.7.0",
146146
"mkdirp": "^0.5.1",
147147
"prettier": "1.19.1",

0 commit comments

Comments
 (0)