title: React Testing Library Invariant failed: You should not use <Route> outside a <Router>
body: <p>I'm testing if my components render with Redux successfully with React Testing Library. I'm having trouble having my utility component to pass the renderWithRedux test. This is my App component.</p>
  <pre><code>function App() {
  return (
      &lt;&gt;
          &lt;Router&gt;
              &lt;NavBar /&gt;
              &lt;div className=&quot;container&quot;&gt;
                  &lt;Switch&gt;
                      &lt;Route exact path='/' component={Home}/&gt;
                      &lt;AuthRoute exact path='/login' component={Login} /&gt;
                      &lt;AuthRoute exact path='/signup' component={Signup} /&gt;
                      &lt;Route exact path='/users/:handle' component={UserProfile} /&gt;
                      &lt;Route exact path='/users/:handle/post/:postId' component={UserProfile} /&gt;
                  &lt;/Switch&gt;
              &lt;/div&gt;
          &lt;/Router&gt;
      &lt;/&gt;
  );
  </code></pre>
  <p>}</p>
  <p>Here is my AuthRoute utility component.</p>
  <pre><code>const AuthRoute = ({ component: Component, authenticated, ...rest }) =&gt; (
        // if authenticated, redirect to homepage, otherwise redirect to signup or login
          &lt;Route
          {...rest}
          render={(props) =&gt;
            authenticated === true ? &lt;Redirect to='/' /&gt; : &lt;Component {...props} /&gt;
          }
        /&gt;
      );
  </code></pre>
  <p>AuthRoute.test.js</p>
  <pre><code>const renderWithRedux = () =&gt; render(
      &lt;Provider store={myStore}&gt;
          &lt;AuthRoute /&gt;
      &lt;/Provider&gt;
  );
  
  it('renders with Redux', () =&gt; {
      const {} = renderWithRedux(&lt;AuthRoute /&gt;);
  });
  </code></pre>
  <p>I've attempted the solutions from <a href="https://stackoverflow.com/questions/55552147/invariant-failed-you-should-not-use-route-outside-a-router">Invariant failed: You should not use &lt;Route&gt; outside a &lt;Router&gt;</a>, but to no avail. I appreciate any help, thank you.</p>