title: Mock.mockImplementation is not a function
body: <p>I've tried to search every single similar issue here, unfortunately no solution worked for me.</p>
  <p>I'm currently trying to mock named exports from a module, that looks like this:</p>
  <p><strong>module.ts</strong></p>
  <pre class="lang-js prettyprint-override"><code>export function someFunctionOne() {
      // implementation
  }
  
  export const someFunctionTwo = function (
  ) {
      // implementation
  }
  
  export const someFunctionThree = () =&gt; {
      // implementation
  }
  
  export const someFunctionFour = () =&gt; {
      // implementation
  }
  </code></pre>
  <p>There are four exports here, and in my tests, I need to mock the whole module:</p>
  <ul>
  <li>Two exports shall be mocked initially to some value, then re-mocked by some tests (but not all)</li>
  <li>Two exports shall only be mocked initially and do not need to be re-mocked as I rely on the same mock for every tests</li>
  </ul>
  <p>Tests look like this:</p>
  <p><strong>module.test.ts</strong></p>
  <pre class="lang-js prettyprint-override"><code>import React from 'react'
  import { shallow } from 'enzyme'
  import Component from './component' // component I am testing
  import { someFunctionOne, someFunctionTwo  } from './module'
  
  ;(jest as any).mock('./module', () =&gt; ({
      someFunctionOne: jest.fn(),
      someFunctionTwo: jest.fn(),
      someFunctionThree: jest.fn(() =&gt; 10),
      someFunctionFour: jest.fn((s) =&gt; s),
  }))
  ;(someFunctionOne as any).mockReturnValue('some String')
  ;(someFunctionTwo as any).mockReturnValue(false)
  
  
  describe('Component', () =&gt; {
      beforeEach(() =&gt; {
          ;(someFunctionOne as any).mockReset()
          ;(someFunctionTwo as any).mockReset()
      })
      it('renders', () =&gt; {
          ;(someFunctionOne as any).mockImplementationOnce(jest.fn(() =&gt; 'some string'))
          ;(someFunctionTwo as any).mockImplementationOnce(jest.fn(() =&gt; false))
          const shallowRenderedModule = shallow(
              &lt;Module&gt;
                  &lt;div&gt;Children textContent here&lt;/div&gt;
              &lt;/Module&gt;
          )
          expect(shallowRenderedModule).toMatchSnapshot()
      })
      // Then, many other tests...
  })
  </code></pre>
  <p>I also have <code>jest</code> and <code>babel-jest</code> configured as so:</p>
  <p><strong>jest.config.js</strong></p>
  <pre class="lang-js prettyprint-override"><code>module.exports = {
      displayName: 'redacted-app',
      setupFilesAfterEnv: ['./jest/jest.setup'],
      preset: '../../jest.preset.js',
      transform: {
          '^.+\\.[tj]sx?$': [
              'babel-jest',
              { cwd: __dirname, configFile: './babel-jest.config.json' },
          ],
          '\\.(svg)$': './jest/svg.transform',
      },
      moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
  }
  
  </code></pre>
  <p><strong>babel-jest.config.json</strong></p>
  <pre><code>{
      &quot;presets&quot;: [
          [
              &quot;@babel/preset-env&quot;,
              {
                  &quot;targets&quot;: {
                      &quot;node&quot;: &quot;current&quot;
                  }
              }
          ],
          &quot;@babel/preset-typescript&quot;,
          &quot;@babel/preset-react&quot;
      ]
  }
  
  </code></pre>
  <p>The problem is, no matter what method I use from <code>Mock</code> (<code>mockImplementation</code>, <code>mockReturnValue</code>, etc) I always end up with <code>_moduleName.someFunctionOne.mockReturnValue is not a function</code>:</p>
  <pre><code>    TypeError: _moduleName.someFunctionOne.mockReturnValue is not a function
  
        10 |      someFunctionFour: jest.fn((s) =&gt; s),
        11 | }))
      &gt; 12 | ;(someFunctionOne as any).mockReturnValue('some String')
           |                     ^
        13 | ;(someFunctionTwo as any).mockReturnValue(false)
  
  </code></pre>
  <p><code>console.log</code>ging it, it seems that indeed, the exports aren't actually mocked.</p>
  <p>I'm at a loss here, what could it be?
  I've tried:</p>
  <ul>
  <li>Using a dummy function inside the original <code>jest.fn()</code> e.g <code>jest.fn(() =&gt; {})</code></li>
  <li>Not using a jest mock function at all in the original mock e.g <code>someFunctionOne: () =&gt; {}</code></li>
  <li>Not using <code>mockReturnValue</code> in line 12 and mock it directly in <code>jest.fn()</code></li>
  <li>Chaining <code>mockImplementationOnce</code> to the initial module mock</li>
  </ul>
  <p>But none of these worked.</p>