title: How to mock external module method?
body: <p>I have this module with a function in it:</p>
  
  <pre><code>const utils = {
    redirectTo(url) {
      if (url) {
        window.location = url;
      }
    },
  };
  
  export default utils;
  </code></pre>
  
  <p>It is used somewhere in a React component like this:</p>
  
  <pre><code>import utils from '../../lib/utils';
  
  componentWillUpdate() {
    this.redirectTo('foo')
  }
  </code></pre>
  
  <p>Now I want to check that the value that <code>redirectTo</code> is called with equals <code>foo</code>.</p>
  
  <pre><code>  it('should redirect if no rights', () =&gt; {
      const mockRedirectFn = jest.fn();
      utils.redirectTo = mockRedirectFn;
  
      mount(
        &lt;SomeComponent /&gt;,
      );
  
      expect(mockRedirectFn).toBeCalled();
      expect(mockRedirectFn).toBeCalledWith('foo');
      console.log(mockRedirectFn.mock);
      // { calls: [], instances: [] }
    });
  </code></pre>
  
  <p>Thats what I've got and it does not work. How do I do this?</p>