Skip to content

Mock not working #23

Closed
Closed
@piranna

Description

@piranna

On Node.js v8.9.1, seems that require.cache is per module and mock.js script side effects are not working. I've done some traces both on mock.js and my setupTests.js file (that calls the first one) and they are different:

  console.log node_modules/react-native-mock-render/mock.js:13
    { '/home/piranna/Trabajo/Quantum/flowtag_react/node_modules/react-native/Libraries/react-native/react-native-implementation.js': 
       { id: '/home/piranna/Trabajo/Quantum/flowtag_react/node_modules/react-native/Libraries/react-native/react-native-implementation.js',
         filename: '/home/piranna/Trabajo/Quantum/flowtag_react/node_modules/react-native/Libraries/react-native/react-native-implementation.js',
         loaded: true,
         exports: 
          { ActivityIndicator: [Object],
            ActivityIndicatorIOS: [Object],
            ART: [Object],
            Button: [Object],
            DatePickerIOS: [Object],
            DrawerLayoutAndroid: [Object],
            Image: [Object],
            ImageBackground: [Object],
            ImageEditor: [Object],
            ImageStore: [Object],
            KeyboardAvoidingView: [Object],
            ListView: [Object],
            MapView: [Object],
            Modal: [Object],
            Navigator: [Object],
            NavigatorIOS: [Object],
            Picker: [Object],
            PickerIOS: [Object],
            ProgressBarAndroid: [Object],
            ProgressViewIOS: [Object],
            ScrollView: [Object],
            SegmentedControlIOS: [Object],
            SliderIOS: [Object],
            SnapshotViewIOS: [Object],
            Switch: [Object],
            PullToRefreshViewAndroid: [Object],
            RecyclerViewBackedScrollView: [Object],
            RefreshControl: [Object],
            StatusBar: [Object],
            SwitchAndroid: [Object],
            SwitchIOS: [Object],
            TabBarIOS: [Object],
            Text: [Object],
            TextInput: [Object],
            ToastAndroid: [Object],
            ToolbarAndroid: [Object],
            Touchable: [Object],
            TouchableHighlight: [Object],
            TouchableNativeFeedback: [Object],
            TouchableOpacity: [Object],
            TouchableWithoutFeedback: [Object],
            View: [Object],
            ViewPagerAndroid: [Object],
            WebView: [Object],
            ActionSheetIOS: [Object],
            Alert: [Object],
            AlertIOS: [Function: AlertIOS],
            Animated: [Object],
            AppRegistry: [Object],
            AppState: [Object],
            AppStateIOS: [Object],
            AsyncStorage: [Object],
            BackAndroid: [Object],
            BackHandler: [Object],
            CameraRoll: [Object],
            Clipboard: [Object],
            DatePickerAndroid: [Function: DatePickerAndroid],
            Dimensions: [Object],
            Easing: [Function: Easing],
            ImagePickerIOS: [Object],
            IntentAndroid: [Function: IntentAndroid],
            InteractionManager: [Object],
            Keyboard: [Object],
            LayoutAnimation: [Object],
            Linking: [Function: Linking],
            LinkingIOS: [Function: LinkingIOS],
            NetInfo: [Object],
            PanResponder: [Object],
            PixelRatio: [Object],
            PushNotificationIOS: [Function: PushNotificationIOS],
            Settings: [Object],
            StatusBarIOS: [Object],
            StyleSheet: [Object],
            TimePickerAndroid: [Function: TimePickerAndroid],
            UIManager: [Object],
            VibrationIOS: [Object],
            DeviceEventEmitter: [Object],
            NativeAppEventEmitter: [Object],
            NativeEventEmitter: [Function: NativeEventEmitter],
            NativeModules: [Object],
            Platform: [Object],
            processColor: [Function: processColor],
            requireNativeComponent: [Function: requireNativeComponent],
            ColorPropType: [Function: ColorPropType],
            EdgeInsetsPropType: [Object],
            PointPropType: [Object],
            NavigationExperimental: [Object],
            ViewPropTypes: [Object],
            Children: [Object],
            Component: [Function: Component],
            PureComponent: [Function: PureComponent],
            unstable_AsyncComponent: [Function: AsyncComponent],
            createElement: [Function: createElementWithValidation],
            cloneElement: [Function: cloneElementWithValidation],
            createFactory: [Function: createFactoryWithValidation],
            isValidElement: [Function: isValidElement],
            version: '16.1.1',
            __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: [Object],
            addons: [Object] } } }
  console.log src/setupTests.js:25
    {}

Am I doing something terrible wrong, or effectively require.cache now is per-module?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions