title: Mocking useHistory and expect toBeCalledWith
body: <p>I wan't to check if <code>history.push()</code> has been called with the correct parameters in my test. 
  I'm not sure what's the correct way to mock <code>useHistory()</code></p>
  
  <p>I tried <a href="https://stackoverflow.com/a/58581010/3247934">this</a> solution. But it seems that I can't check if <code>push()</code> has been called.</p>
  
  <p>App.tsx</p>
  
  <pre class="lang-js prettyprint-override"><code>import React from 'react';
  import {useHistory} from 'react-router-dom';
  
  const App: React.FC = () =&gt; {
      const history = useHistory();
      const onClick = () =&gt; {
          history.push('/anotherPath');
      };
      return (
          &lt;div&gt;
              &lt;button onClick={onClick}&gt;click&lt;/button&gt;
          &lt;/div&gt;
      );
  };
  
  export default App;
  
  </code></pre>
  
  <p>App.test.tsx</p>
  
  <pre class="lang-js prettyprint-override"><code>import React from 'react';
  import {render, fireEvent} from '@testing-library/react';
  import App from './App';
  import {useHistory} from 'react-router-dom'
  
  jest.mock('react-router-dom', () =&gt; ({
      useHistory: () =&gt; ({
          push: jest.fn(),
      }),
  }));
  
  test('renders learn react link', async () =&gt; {
      const app = render(&lt;App/&gt;);
      fireEvent.click(app.getByText('click'));
      expect(useHistory().push).toBeCalledWith('/anotherPath');
  });
  </code></pre>
  
  <p>Is there any way to make sure that <code>history.push()</code> has been called with the correct parameters?</p>