title: How to spy on a default exported function with Jest?
body: <p>Suppose I have a simple file exporting a default function:</p>
  
  <pre><code>// UniqueIdGenerator.js
  const uniqueIdGenerator = () =&gt; Math.random().toString(36).substring(2, 8);
  
  export default uniqueIdGenerator;
  </code></pre>
  
  <p>Which I would use like this:</p>
  
  <pre><code>import uniqueIdGenerator from './UniqueIdGenerator';
  // ...
  uniqueIdGenerator();
  </code></pre>
  
  <p>I want to assert in my test that this method was called while keeping the original functionality. I'd do that with <code>jest.spyOn</code> however, it requires an object as well as a function name as parameters. How can you do this in a clean way? There's a similar <a href="https://github.com/jasmine/jasmine/issues/1414" rel="noreferrer">GitHub issue</a> for <code>jasmine</code> for anyone interested.</p>