Skip to content

Commit

Permalink
Upgrade to Jest 25
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cpojer authored and facebook-github-bot committed Apr 20, 2020
1 parent 7cc791b commit f248ba1
Show file tree
Hide file tree
Showing 7 changed files with 1,363 additions and 832 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ exports[`<ActivityIndicator /> should render as expected: should deep render whe
`;

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

exports[`<ActivityIndicator /> should render as expected: should shallow render as <ActivityIndicator /> when not mocked 1`] = `
<ForwardRef(ActivityIndicator)
<ActivityIndicator
animating={true}
color="#0000ff"
hidesWhenStopped={true}
Expand Down
4 changes: 1 addition & 3 deletions Libraries/Components/Pressable/__tests__/Pressable-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ import View from '../../View/View';
import {expectRendersMatchingSnapshot} from '../../../Utilities/ReactNativeTestTools';

describe('<Pressable />', () => {
/* eslint-disable jest/no-disabled-tests */
// TODO(cpojer): Reenable this test, see T64907347.
xit('should render as expected', () => {
it('should render as expected', () => {
expectRendersMatchingSnapshot(
'Pressable',
() => (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<Pressable /> should render as expected: should deep render when mocked (please verify output manually) 1`] = `
<View
accessible={true}
focusable={true}
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
>
<View />
</View>
`;

exports[`<Pressable /> should render as expected: should deep render when not mocked (please verify output manually) 1`] = `
<View
accessible={true}
focusable={true}
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
>
<View />
</View>
`;

exports[`<Pressable /> should render as expected: should shallow render as <Pressable /> when mocked 1`] = `
<Memo(Pressable)>
<View />
</Memo(Pressable)>
`;

exports[`<Pressable /> should render as expected: should shallow render as <Pressable /> when not mocked 1`] = `
<Memo(Pressable)>
<View />
</Memo(Pressable)>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,21 @@ exports[`<ScrollView /> should render as expected: should deep render when not m
`;

exports[`<ScrollView /> should render as expected: should shallow render as <ScrollView /> when mocked 1`] = `
<ForwardRef(ScrollView)>
<ScrollView>
<View>
<Text>
Hello World!
</Text>
</View>
</ForwardRef(ScrollView)>
</ScrollView>
`;

exports[`<ScrollView /> should render as expected: should shallow render as <ScrollView /> when not mocked 1`] = `
<ForwardRef(ScrollView)>
<ScrollView>
<View>
<Text>
Hello World!
</Text>
</View>
</ForwardRef(ScrollView)>
</ScrollView>
`;
2 changes: 1 addition & 1 deletion Libraries/Image/__tests__/__snapshots__/Image-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ exports[`<Image /> should render as <RCTImageView> when not mocked 1`] = `
`;
exports[`<Image /> should shallow render as <ForwardRef(Image)> when not mocked 1`] = `
<ForwardRef(Image)
<Image
source={
Object {
"uri": "foo-bar.jpg",
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"metro-react-native-babel-transformer": "0.59.0",
"metro-source-map": "0.59.0",
"nullthrows": "^1.1.1",
"pretty-format": "^24.9.0",
"pretty-format": "^25.4.0",
"promise": "^8.0.3",
"prop-types": "^15.7.2",
"react-devtools-core": "^4.6.0",
Expand Down Expand Up @@ -140,8 +140,8 @@
"eslint-plugin-relay": "1.7.0",
"flow-bin": "^0.122.0",
"flow-remove-types": "1.2.3",
"jest": "^24.9.0",
"jest-junit": "^6.3.0",
"jest": "^25.4.0",
"jest-junit": "^10.0.0",
"jscodeshift": "^0.7.0",
"mkdirp": "^0.5.1",
"prettier": "1.19.1",
Expand Down
Loading

0 comments on commit f248ba1

Please sign in to comment.