add jest config for react-navigation in docs (#256) (#331)

* add jest config for react-navigation in docs (#256)

* Docs: Update redux-integration guide #246
This commit is contained in:
Michel Maubert 2017-04-04 19:02:21 +02:00 committed by Eric Vicenti
parent 83f8a44219
commit e8726c1e68

View File

@ -11,7 +11,7 @@ const AppNavigator = StackNavigator(AppRouteConfigs);
const navReducer = (state, action) => {
const newState = AppNavigator.router.getStateForAction(action, state);
return newState || state;
return (newState ? newState : state)
};
const appReducer = combineReducers({
@ -61,3 +61,16 @@ const AppNavigator = StackNavigator({
```
In this case, once you `connect` `AppNavigator` to Redux as is done in `AppWithNavigationState`, `MyTabNavigator` will automatically have access to navigation state as a `navigation` prop.
## Mocking tests
To make jest tests work with your react-navigation app, you need to change the jest preset in the `package.json`, see [here](https://facebook.github.io/jest/docs/tutorial-react-native.html#transformignorepatterns-customization):
```
"jest": {
"preset": "react-native",
"transformIgnorePatterns": [
"node_modules/(?!(jest-)?react-native|react-navigation)"
]
}
```