title: Mock an entire module with Jest in Javascript
body: <p>I searched for a very long time how to mock any module with jest (like rewire does). I finally manage to do it this way, and it work like a charm : </p>
  
  <pre><code>jest.mock('common/js/browser-utils', () =&gt; ({
      openBrowser: jest.fn()
  }));
  const { openBrowser: openBrowserSpy } = jest.requireMock(
      'common/js/browser-utils'
  );
  </code></pre>
  
  <p>But i wonder if there is another fast way to do so ?
  I saw the <code>genMockFromModule</code> method but i never makes it work (maybe it's not for that usage.)</p>
  
  <p>What i want is simple : mocking a module by a <code>jest.fn()</code> (or any auto mechanism), then being able to access this jest.fn() in my tests (here: <code>openBrowserSpy</code>) to <code>expect(assertions)</code> on it</p>