title: MemoryRouter and jest test
body: <p><a href="https://reacttraining.com/react-router/web/guides/testing" rel="noreferrer">https://reacttraining.com/react-router/web/guides/testing</a></p>
  
  <p>The react-router testing documentation is bit obscure to me.</p>
  
  <p>How to write a test to check a  route is rendered</p>
  
  <p>A Component. - <em>APage.js</em></p>
  
  <pre><code>import React, { Component } from 'react'
  
  
  export default class APage extends Component {
    render() {
      return (
        &lt;div&gt;
          A Page
        &lt;/div&gt;
      )
    }
  }
  </code></pre>
  
  <p>Writing a unit test to check , as per documentation.</p>
  
  <p><em>routes.test.js</em></p>
  
  <pre><code>import React from 'react'
  import { render } from "react-dom";
  import APage from './APage'
  import {MemoryRouter} from 'react-router-dom';
  
    test("render route", () =&gt; {
      render(
        &lt;MemoryRouter initialEntries={["/apage"]}&gt;
          &lt;APage /&gt;
        &lt;/MemoryRouter&gt;
      );
    });
  </code></pre>
  
  <p>It gives an error, 
  Invariant Violation: Target container is not a DOM element.
  for render.</p>
  
  <p>How do I write a basic test, like to test a component is rendered on a route.</p>