From e8726c1e683cd3a6cafc9ba1e3a97a0f197c98dd Mon Sep 17 00:00:00 2001 From: Michel Maubert Date: Tue, 4 Apr 2017 19:02:21 +0200 Subject: [PATCH] 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 --- docs/guides/Redux-Integration.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/guides/Redux-Integration.md b/docs/guides/Redux-Integration.md index 6718663..30d95c6 100644 --- a/docs/guides/Redux-Integration.md +++ b/docs/guides/Redux-Integration.md @@ -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)" + ] +} +```