title: Testing react-router with Shallow rendering
body: <p>I have my react-router component such as : </p>
  
  <pre><code>&lt;Switch&gt;
    &lt;Route
      path="/abc"
      render={() =&gt; &lt;ComponentTemplateABC component={containerABC} /&gt;}
    /&gt;
    &lt;Route
      path="/def"
      render={() =&gt; &lt;ComponentTemplateDEF component={containerDEF} /&gt;}
    /&gt;
    ...
    ...
  &lt;/Switch&gt;
  </code></pre>
  
  <p>I wish to test the routing to ensure the respective component is rendered for each route. However, I do not wish to use mount for testing the routing, only wish to use shallow rendering. </p>
  
  <p>Below is what my test looks like currently: </p>
  
  <pre><code>  test('abc path should route to containerABC component', () =&gt; {
      const wrapper = shallow(
        &lt;Provider store={store}&gt;
          &lt;MemoryRouter initialEntries={['/abc']}&gt;
            &lt;Switch&gt;
              &lt;AppRouter /&gt;
            &lt;/Switch&gt;
          &lt;/MemoryRouter&gt;
        &lt;/Provider&gt;,
      );
      jestExpect(wrapper.find(containerABC)).toHaveLength(1);
    });
  </code></pre>
  
  <p>This test does not work with shallow, because shallow won't render the full child hierarchy. So I tried an alternate approach: </p>
  
  <pre><code>test('abc path should render correct routes and route to containerABC component', () =&gt; {
   const wrapper = shallow(&lt;AppRouter /&gt;);
  
   const pathMap = wrapper.find(Route).reduce((pathMap, route) =&gt; {
   const routeProps = route.props();
   pathMap[routeProps.path] = routeProps.component;
   return pathMap;
   }, {});
  
   jestExpect(pathMap['/abc']).toBe(containerABC);
  });
  </code></pre>
  
  <p>This test does not work for me, because I am using render in my routing code instead of Component directly as in below: </p>
  
  <pre><code>&lt;Route path="..." **render**={() =&gt; &lt;Component.. component={container..} /&gt;}
  </code></pre>
  
  <p>Hence, I am unable to test my routes. How do I test my routes using shallow rendering or as above or basically, any other approach that does not use mount?</p>
  
  <p>Any help would be much appreciated.
  Thank you in advance.</p>