Skip to content

[CI] Fix test_javascript Snapshot Test failure #19308

@hramos

Description

@hramos

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).

Details ● VirtualizedList › handles nested lists
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 803afd8.

You can reproduce the failure locally by following the repro steps below.

Environment

CircleCI

Steps to Reproduce

  1. Checkout master
  2. yarn add --dev jest@23.0.0-charlie.2
  3. yarn test

Expected Behavior

Tests should pass.

Actual Behavior

Snapshot tests fail due to non-matching snapshots.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions