react-navigation/react-native-safe-area-view

Large `forwardedRef` in snapshot, causes test to sometimes error

pstrum opened this issue · 2 comments

This could be related to issue #90.

When I run a toMatchSnapshot() with <SafeAreaView> in the render, it results in a very large forwardedRef object in the .snap file, or causes the test to crash because it is so large. Here is an example:

test('Safe area view crashes test', () => {
  ...
  const screen = render(
    <Provider store={store}>
      <SafeAreaProvider initialSafeAreaInsets={{ top: 1, left: 2, right: 3, bottom: 4 }}>
        <View>
          <View>
            <SafeAreaView>
              <Text>Hello</Text>
            </SafeAreaView>
          </View>
        </View>
      </SafeAreaProvider>
    </Provider>
  );
  expect(screen.toJSON()).toMatchSnapshot();
});
FAIL name.test.tsx
• screen renders
PrettyFormatPluginError: Invalid string lengthRangeError: Invalid string length

Interestingly, if I have one less nested view, that test will be successful.

This happens after upgrading React Native from 0.61.5 to 0.63.3. Any advice greatly appreciated. Let me know more details I can provide.

Details
"react-native-safe-area-context": "^0.7.3"
"react-native-safe-area-view": "^1.1.1",
"jest": "^25.1.0"

Also hitting this, does anyone have any suggestions?

this library is deprecated, use react-native-safe-area-context instead :)