title: How to mock jest function importing from another file as default
body: <p>My question is about how to mock jest function importing from another file as default.</p>
  
  <p>What I want to test is that component using function to enabled Feature (<code>Features.js</code>)</p>
  
  <p>I mocked this function using <strong>jest.fn()</strong> and tried to change value using <strong>mockReturnValueOnce</strong></p>
  
  <p>It looks like below.</p>
  
  <p>mocks/features.js</p>
  
  <pre><code>export default function isFeatureEnabled (featureName) {
    return true // want to test both true/false cases 
  }
  </code></pre>
  
  <p>test.spec.js</p>
  
  <pre><code>jest.mock('__mocks__/features.js', () =&gt; ({
    isFeatureEnabled: jest.fn()
  }))
  
  describe('isFeatureEnabled', () =&gt; {
    it('isFeatureEnabled=[true]', () =&gt; {
      isFeatureEnabled.mockReturnValueOnce(true)
     // some tests
    })
    it('isFeatureEnabled=[false]', () =&gt; {
      isFeatureEnabled.mockReturnValueOnce(false)
     // some tests
    })
  })
  
  </code></pre>
  
  <p>When I run the test, I got an error says <code>mockReturnValueOnce is not a function</code>. This <a href="https://stackoverflow.com/questions/45758366/how-to-change-jest-mock-function-return-value-in-each-test/52279609#52279609">stackoverflow question</a> inspired me to implement in this way, however still I cannot figure it out how to make it working.</p>