title: Testing async method using React testing library
body: <p>I have button in component:</p>
  <pre><code>&lt;button
      type=&quot;button&quot;
      title=&quot;Logout&quot;
      data-testid=&quot;logout&quot;
      onClick={logout}
  &gt;
  </code></pre>
  <p>and method <code>logout</code>:</p>
  <pre><code>const logout = async () =&gt; {
      try {
          await authLogout()
      } catch (error) {
          console.error(error)
      } finally {
          props.history.push('/login')
      }
  }
  </code></pre>
  <p>Now I trying testing logout method by click on button:</p>
  <pre><code>describe('UserMenuComponent', () =&gt; {
    it('go to login page after click on logout', async () =&gt; {
      const history = createMemoryHistory()
  
      const { getByTestId } = render(
        &lt;Router history={history}&gt;
          &lt;UserMenuComponent /&gt;,
        &lt;/Router&gt;,
        {
          initialState: { reducersAuth: initialState },
        },
      )
  
      fireEvent.click(getByTestId('logout'))
      expect(history.location.pathname).toBe('/login')
    })
  })
  </code></pre>
  <p>Inside method <code>logout</code> in <code>finally</code> block I have <code>props.history.push('/login')</code> and I check this in my test: <code>expect(history.location.pathname).toBe('/login')</code> but test return error:</p>
  <pre><code>expect(received).toBe(expected) // Object.is equality
  
  Expected: &quot;/login&quot;
  Received: &quot;/&quot;
  </code></pre>