diff --git a/examples/__tests__/react-navigation.js b/examples/__tests__/react-navigation.js index e123b5d..1be2baa 100644 --- a/examples/__tests__/react-navigation.js +++ b/examples/__tests__/react-navigation.js @@ -5,15 +5,17 @@ import { createStackNavigator, createAppContainer, withNavigation } from 'react- import { render, fireEvent } from '../../src'; -jest.mock('NativeAnimatedHelper').mock('react-native-gesture-handler', () => { - const View = require('react-native').View; - return { - State: {}, - PanGestureHandler: View, - BaseButton: View, - Directions: {}, - }; -}); +jest + .mock('react-native/Libraries/Animated/src/NativeAnimatedHelper') + .mock('react-native-gesture-handler', () => { + const View = require('react-native').View; + return { + State: {}, + PanGestureHandler: View, + BaseButton: View, + Directions: {}, + }; + }); const Home = ({ navigation }) => ( diff --git a/src/preset/configure.js b/src/preset/configure.js index 385b308..30fe655 100644 --- a/src/preset/configure.js +++ b/src/preset/configure.js @@ -16,23 +16,23 @@ configureNTL({ // Query lists coreComponents: [ - 'ActivityIndicator', - 'Button', - 'DrawerLayoutAndroid', - 'Image', - 'Modal', - 'Picker', - 'RefreshControl', - 'SafeAreaView', - 'ScrollView', - 'Switch', - 'Text', - 'TextInput', - 'TouchableHighlight', - 'TouchableNativeFeedback', - 'TouchableOpacity', - 'TouchableWithoutFeedback', - 'View', + 'react-native/Libraries/Components/ActivityIndicator/ActivityIndicator', + 'react-native/Libraries/Components/Button', + 'react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid', + 'react-native/Libraries/Image/Image', + 'react-native/Libraries/Modal/Modal', + 'react-native/Libraries/Components/Picker/Picker', + 'react-native/Libraries/Components/RefreshControl/RefreshControl', + 'react-native/Libraries/Components/SafeAreaView/SafeAreaView', + 'react-native/Libraries/Components/ScrollView/ScrollView', + 'react-native/Libraries/Components/Switch/Switch', + 'react-native/Libraries/Text/Text', + 'react-native/Libraries/Components/TextInput/TextInput', + 'react-native/Libraries/Components/Touchable/TouchableHighlight', + 'react-native/Libraries/Components/Touchable/TouchableNativeFeedback', + 'react-native/Libraries/Components/Touchable/TouchableOpacity', + 'react-native/Libraries/Components/Touchable/TouchableWithoutFeedback', + 'react-native/Libraries/Components/View/View', ], displayValueComponents: ['TextInput', 'Picker', 'Switch'], textComponents: ['Button', 'Text', 'TextInput'], diff --git a/src/preset/mock-modules.js b/src/preset/mock-modules.js index 20e4bb7..566bc78 100644 --- a/src/preset/mock-modules.js +++ b/src/preset/mock-modules.js @@ -13,7 +13,7 @@ getConfig('coreComponents').forEach(component => { }); // Un-mock ReactNative so we can hide annoying `console.warn`s -jest.unmock('ReactNative'); +jest.unmock('react-native/Libraries/Renderer/shims/ReactNative'); // Mock the components we want mocked getConfig('coreComponents').forEach(component => { @@ -23,21 +23,23 @@ getConfig('coreComponents').forEach(component => { }); // Mock the Picker one-off because it's kinda weird -jest.doMock('Picker', () => { +jest.doMock('react-native/Libraries/Components/Picker/Picker', () => { const React = jest.requireActual('react'); - const Picker = mockComponent('Picker'); + const Picker = mockComponent('react-native/Libraries/Components/Picker/Picker'); Picker.Item = ({ children, ...props }) => React.createElement('Picker.Item', props, children); return Picker; }); // Re-mock ReactNative with native methods mocked -jest.mock('NativeAnimatedHelper').doMock('ReactNative', () => { - const ReactNative = jest.requireActual('ReactNative'); - const NativeMethodsMixin = - ReactNative.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.NativeMethodsMixin; +jest + .mock('react-native/Libraries/Animated/src/NativeAnimatedHelper') + .doMock('react-native/Libraries/Renderer/shims/ReactNative', () => { + const ReactNative = jest.requireActual('react-native/Libraries/Renderer/shims/ReactNative'); + const NativeMethodsMixin = + ReactNative.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.NativeMethodsMixin; - Object.assign(NativeMethodsMixin, mockNativeMethods); - Object.assign(ReactNative.NativeComponent.prototype, mockNativeMethods); + Object.assign(NativeMethodsMixin, mockNativeMethods); + Object.assign(ReactNative.NativeComponent.prototype, mockNativeMethods); - return ReactNative; -}); + return ReactNative; + });