title: How to mock a global commonjs method with jest?
body: <p>I try to test some basic redux reducers with jest and stumbled about a problem I can't solve on my own:</p>
  
  <p>In my reducer I'm referencing a global method "__" (some i18n stuff), which implementation basically looks like the following:</p>
  
  <pre><code>window.__ = function(foo) { return window.i18n[foo]; }
  </code></pre>
  
  <p>The mentioned method is referenced in another module I include in my reducer via <code>import definitions from 'definitions';</code></p>
  
  <p>The definitions file looks like the following:</p>
  
  <pre><code>/* global __ */
  // some basic stuff
  export default () {
    return __('foobar');
  }
  </code></pre>
  
  <p>How is it possible to mock the <code>__</code> method within the test code? Given that <code>__</code> is not a module it can't be automocked. :/</p>