aksonov / react-native-router-flux

The first declarative React Native router
MIT License
8.99k stars 2.11k forks source link

Jest is not working #3680

Closed RicardoBrito1938 closed 4 years ago

RicardoBrito1938 commented 4 years ago

Hello team, i am trying to run tests on my code, but on configuration i found the following error

image

after i added in my jest config

"transformIgnorePatterns": [
  "node_modules/(?!react-native|react-navigation)"
]

now i have the followgin error

image

does anyone have an idea how to fix it?

RicardoBrito1938 commented 4 years ago

in case some one had the same issue i figured by adding


      "node_modules/(?!(jest-)?react-native|@react-native-community|react-navigation|react-navigation-redux-helpers|@react-navigation/.*)"
    ]```

and then mocking on my jest.setup

```  jest.mock('react-native-gesture-handler', () => {
  // eslint-disable-next-line global-require
  const View = require('react-native/Libraries/Components/View/View');
  return {
    Swipeable: View,
    DrawerLayout: View,
    State: {},
    ScrollView: View,
    Slider: View,
    Switch: View,
    TextInput: View,
    ToolbarAndroid: View,
    ViewPagerAndroid: View,
    DrawerLayoutAndroid: View,
    WebView: View,
    NativeViewGestureHandler: View,
    TapGestureHandler: View,
    FlingGestureHandler: View,
    ForceTouchGestureHandler: View,
    LongPressGestureHandler: View,
    PanGestureHandler: View,
    PinchGestureHandler: View,
    RotationGestureHandler: View,
    /* Buttons */
    RawButton: View,
    BaseButton: View,
    RectButton: View,
    BorderlessButton: View,
    /* Other */
    FlatList: View,
    gestureHandlerRootHOC: jest.fn(),
    Directions: {},
  };
});

jest.mock('react-native-reanimated', () =>
  require('react-native-reanimated/mock')
);
jest.mock('react-native-tab-view', () => {});```