title: How to change the behaviour of a mocked import?
body: <p>I am quite confused with mocking in Jest an how to unit test the implementations. The thing is i want to mock different expected behaviours. </p>
  
  <p>Is there any way to achieve this? as imports can be only on the top of the file and to be able to mock something it must be declared before the import. I have also tried to pass a local function so I could overwrite the behaviour but jest complains you are not allowed to pass anything local.</p>
  
  <pre><code>jest.mock('the-package-to-mock', () =&gt; ({
    methodToMock: jest.fn(() =&gt; console.log('Hello'))
  }));
  
  import * as theThingToTest from '../../../app/actions/toTest'
  import * as types from '../../../app/actions/types'
  
  it('test1', () =&gt; {
    expect(theThingToTest.someAction().type).toBe(types.SOME_TYPE)
  })
  
  it('test2', () =&gt; {
    //the-package-to-mock.methodToMock should behave like something else
    expect(theThingToTest.someAction().type).toBe(types.SOME_TYPE)
  })
  </code></pre>
  
  <p>internally as you can imagine <code>theThingToTest.someAction()</code> uses <code>the-package-to-mock.methodToMock</code></p>