title: TypeError: Cannot read property 'pathname' of undefined in react/redux testing
body: <p>I'm testing some react components, a basic tests suite just to know if a component is rendering and their childs.</p>
  
  <p>I'm using <code>redux-mock-store</code> to make the store and <code>{mount} enzyme</code> to mount the container in a provider, but even mocking the correct store this error is always fired:</p>
  
  <blockquote>
    <p>TypeError: Cannot read property 'pathname' of undefined</p>
  </blockquote>
  
  <p>Here is my very deadly basic test:</p>
  
  <pre><code>import React from 'react';
  import { mount } from 'enzyme';
  import configureStore from 'redux-mock-store';
  import { Provider } from 'react-redux';
  import App from '../containers/App.container';
  
  describe('App', () =&gt; {
    let wrapper;
    const mockStore = configureStore([]);
    const store = mockStore({
      router: {
        location: { pathname: '/home', query: {}, search: '' },
        params: {}
      }
    });
    console.log(store.getState());
    beforeEach(() =&gt; {
      wrapper = mount(
        &lt;Provider store={store}&gt;
          &lt;App /&gt;
        &lt;/Provider&gt;
      );
    });
  
    it('Should render app and container elements', () =&gt; {
      expect(wrapper.find('.app').exists()).toBeTruthy();
      expect(wrapper.find('.container').exists()).toBeTruthy();
    });
  
    it('Should render the navbar', () =&gt; {
      expect(wrapper.find('nav').exists()).toBeTruthy();
    });
  });
  </code></pre>
  
  <p>And the (even more) simple component / container:</p>
  
  <pre><code>import React, { Component } from 'react';
  import NavBar from '../components/Navbar';
  
  class App extends Component {
  
    render() {
      const { location, logout} = this.props;
      console.log(location);
      return (
        &lt;section className='app'&gt;
          &lt;NavBar location={location.pathname} onLogoutClick={logout}/&gt;
          &lt;div className='container'&gt;
            {this.props.children}
          &lt;/div&gt;
        &lt;/section&gt;
      );
    }
  }
  
  export default App;
  </code></pre>
  
  <p>Container:</p>
  
  <pre><code>import { connect } from 'react-redux';
  import { signOut } from '../actions/auth.actions'
  import App from '../components/App';
  
  const mapStateToProps = (state, ownProps) =&gt; {
    return {
      location: ownProps.location
    }
  }
  
  const mapDispatchToProps = (dispatch, ownProps) =&gt; {
    return {
      logout: () =&gt; {
        dispatch(signOut())
      }
    }
  };
  
  export default connect(mapStateToProps, mapDispatchToProps)(App);
  </code></pre>
  
  <p>I can't figure out the problem of the test, the mockStore is in the correct format:</p>
  
  <p><a href="https://i.stack.imgur.com/RIWcU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RIWcU.png" alt="enter image description here"></a></p>
  
  <p>Any idea?</p>
  
  <hr>
  
  <p><strong>Update:</strong></p>
  
  <p>Thinking about it, I have no reducer / prop in the rootReducer for the location, but, i just want to pass down through the children components the location object properties that <code>react-redux-router</code> make available in the <code>ownProps</code> argument.</p>
  
  <p>Weird fact: logging the <code>location</code> property in the app returns me the correct object.</p>
  
  <p>In the tests, is always undefined... (as the error shows).</p>
  
  <p><a href="https://i.stack.imgur.com/vk7s7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vk7s7.png" alt="enter image description here"></a></p>
  
  <p>Here is my rootReducer:</p>
  
  <pre><code>import { combineReducers } from 'redux';
  import { reducer as formReducer } from 'redux-form';
  import { routerReducer } from 'react-router-redux';
  
  import authReducer from './auth.reducer';
  import analysisReportsReducer from './AnalysisReports.reducer';
  import titleAnalysisReducer from './TitleAnalysis.reducer';
  import postsReportsReducer from './PostsReports.reducer';
  
  const rootReducer = combineReducers({
    form:             formReducer,
    routing:          routerReducer,
    auth:             authReducer,
    analysis:         titleAnalysisReducer,
    analysis_reports: analysisReportsReducer,
    posts:            postsReportsReducer
  });
  
  export default rootReducer;
  </code></pre>