title: How to mock imported named function in Jest when module is unmocked
body: <p>I have the following module I'm trying to test in Jest:</p>
  
  <pre><code>// myModule.js
  
  export function otherFn() {
    console.log('do something');
  }
  
  export function testFn() {
    otherFn();
  
    // do other things
  }
  </code></pre>
  
  <p>As shown above, it exports some named functions and importantly <code>testFn</code> uses <code>otherFn</code>.</p>
  
  <p>In Jest when I'm writing my unit test for <code>testFn</code>, I want to mock the <code>otherFn</code> function because I don't want errors in <code>otherFn</code> to affect my unit test for <code>testFn</code>. My issue is that I'm not sure the best way to do that:</p>
  
  <pre><code>// myModule.test.js
  jest.unmock('myModule');
  
  import { testFn, otherFn } from 'myModule';
  
  describe('test category', () =&gt; {
    it('tests something about testFn', () =&gt; {
      // I want to mock "otherFn" here but can't reassign
      // a.k.a. can't do otherFn = jest.fn()
    });
  });
  </code></pre>
  
  <p>Any help/insight is appreciated.</p>