title: How to test anchor's href with react-testing-library
body: <p>I am trying to test my anchor tag. Once I click it, I want to see if the <code>window.location.href</code> is what I expect.</p>
  
  <p>I've tried to render the anchor, click it, and then test <code>window.location.href</code>:</p>
  
  <pre class="lang-js prettyprint-override"><code>test('should navigate to ... when link is clicked', () =&gt; {
    const { getByText } = render(&lt;a href="https://test.com"&gt;Click Me&lt;/a&gt;);
  
    const link = getByText('Click Me');
  
    fireEvent.click(link);
  
    expect(window.location.href).toBe("https://www.test.com/");
  });
  </code></pre>
  
  <p>I am expecting the test to pass, but instead the window.location.href is just <code>"http://localhost/"</code> meaning it is not getting updated for whatever reason. I even tried wrapping my expect with <code>await wait</code>, but that didn't work either. I can't find much information about testing anchors with <code>react-testing-library</code>. Maybe there is even a better way to test them than what I am doing. ‍♂️</p>