react-native: [CI] Fix test_javascript Snapshot Test failure
- I have reviewed the documentation
- I have searched existing issues
- I am using the latest React Native version
The test_javascript
job started failing on master
recently: https://circleci.com/gh/facebook/react-native/42926
This is due to failing snapshot tests, mostly in VirtualizedList
(expand details below to see an example).
expect(value).toMatchSnapshot()
Received value does not match stored snapshot "VirtualizedList handles nested lists 1".
- Snapshot
+ Received
@@ -12,11 +12,10 @@
disableVirtualization={false}
getItem={[Function]}
getItemCount={[Function]}
horizontal={false}
initialNumToRender={10}
- invertStickyHeaders={undefined}
keyExtractor={[Function]}
maxToRenderPerBatch={10}
onContentSizeChange={[Function]}
onEndReachedThreshold={2}
onLayout={[Function]}
@@ -49,11 +48,10 @@
disableVirtualization={false}
getItem={[Function]}
getItemCount={[Function]}
horizontal={false}
initialNumToRender={10}
- invertStickyHeaders={undefined}
keyExtractor={[Function]}
maxToRenderPerBatch={10}
onContentSizeChange={[Function]}
onEndReachedThreshold={2}
onLayout={[Function]}
@@ -103,11 +101,10 @@
disableVirtualization={false}
getItem={[Function]}
getItemCount={[Function]}
horizontal={true}
initialNumToRender={10}
- invertStickyHeaders={undefined}
keyExtractor={[Function]}
maxToRenderPerBatch={10}
onContentSizeChange={[Function]}
onEndReachedThreshold={2}
onLayout={[Function]}
158 | />,
159 | );
> 160 | expect(component).toMatchSnapshot();
| ^
161 | });
162 |
163 | it('returns the viewableItems correctly in the onViewableItemsChanged callback after changing the data', () => {
at Object.<anonymous> (Libraries/Lists/__tests__/VirtualizedList-test.js:160:23)
This does not repro on a clean local checkout on my laptop, but after some investigation, I narrowed this down to Jest v23.0.0-charlie.2
being used in CI. While our own package.json
specifies jest v23.0.0-charlie.1
, the metro
package v0.37
depends on jest v23.0.0-charlie.2
and thus this version wins out.
The test started failing once metro was bumped to v0.37
in 803afd8430a87aff0f4aa8d66e5a2905db7d8c36.
You can reproduce the failure locally by following the repro steps below.
Environment
CircleCI
Steps to Reproduce
- Checkout master
yarn add --dev jest@23.0.0-charlie.2
yarn test
Expected Behavior
Tests should pass.
Actual Behavior
Snapshot tests fail due to non-matching snapshots.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16 (16 by maintainers)
Bumping the version to charlie.4 is quite straightforward, but I’d need to codemod the rest of the codebase to handle the breaking change in https://github.com/facebook/jest/pull/6173 as well. Seeing @brunotavares has already done some of this work in another one of our internal repos, I’ll let him or his team tackle this.
RN OSS is using jest@23.0.0-charlie.1 but from I recall, some charlie.2 and charlie.4 modules are getting pulled by Yarn. We use an offline repository internally where charlie.1 is the latest cached version, so we don’t have this issue.
Found your PR, https://github.com/facebook/jest/pull/6173 - I’ll change these to
jest.fn
.