react-native-keyboard-aware-scroll-view icon indicating copy to clipboard operation
react-native-keyboard-aware-scroll-view copied to clipboard

Newest version has a missing check, breaks jest tests

Open kevryan2 opened this issue 3 years ago • 4 comments

Version 0.9.4 released today breaks at line 135 https://prnt.sc/129rhwg.

Addition that caused the issue: https://prnt.sc/129rjt2.

Recommendation: const shouldCallGetNode = !Platform.constants || !Platform.constants.reactNativeVersion || (Platform.constants.reactNativeVersion.major === 0 && Platform.constants.reactNativeVersion.minor < 62)

kevryan2 avatar Apr 29 '21 21:04 kevryan2

Have you managed to find a work around for this @KevRyan2 ?

maxckelly avatar May 02 '21 23:05 maxckelly

I'm running into this same issue upgrading a project to React Native 0.64.0... I ended up mocking the reactNativeVersion object in our testing utility that utilizes react-test-renderer calls in our project. Definitely hoping there's a fix on the way soon.

import { Platform } from 'react-native';
...
Platform.constants.reactNativeVersion = { minor: '64', major: '0' };
...

TNicholson11 avatar May 03 '21 02:05 TNicholson11

Have you managed to find a work around for this @KevRyan2 ?

Yes just hardcode it to an older version in your package.json dependencies. It won't benefit from any upgrades or optimizations until you change that back, but it won't break at least.

kevryan2 avatar May 03 '21 09:05 kevryan2

This is my workaround:

jest.mock('react-native/Libraries/Utilities/Platform', () => {
  const Platform = jest.requireActual('react-native/Libraries/Utilities/Platform');
  Platform.constants.reactNativeVersion = { major: 0, minor: 64, patch: 0 };
  return Platform;
});

robrechtme avatar May 05 '21 13:05 robrechtme