title: Testing navigation with react-testing-library
body: <p>I want to test if a sidebar that I have created for navigation works or not, this is a simple example of what I have made</p>
  <pre><code>&lt;ul&gt;
    &lt;li&gt;&lt;Link to=&quot;/location1&quot;&gt;location 1&lt;/Link&gt;&lt;/li&gt;
    &lt;li&gt;&lt;Link to=&quot;/location2&quot;&gt;location 2&lt;/Link&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  <p>this is my test</p>
  <pre><code>const routerWrapper = ({children}) =&gt; &lt;BrowserRouter&gt;{children}&lt;/BrowserRouter&gt;
  
  // The first one runs fine
  it('navigation to location 1' , () =&gt; {
  render(&lt;SideBar/&gt; , {wrapper:routerWrapper})
  // get the element and click on it
  // check if title of page is correct
  })
  
  it('navigation to location 2' , () =&gt; {
  render(&lt;SideBar/&gt; , {wrapper:routerWrapper})
  // can't run because location is at /location1
  })
  </code></pre>
  <p>When I test the navigation with RTL, first test runs fine, but after that the location remains at that directory for next test, how do I clear location after every test? or any suggestions how should I test navigation?</p>