title: How to mock only one exported function in jest?
body: <p>I am trying to mock a single function in my test inside a module.
  This is the module, where I need to mock only <code>generateServerSeed</code></p>
  
  <pre><code>// seeds.js
  const crypto = require('crypto');
  
  const generateServerSeed = function () {
      return crypto.randomBytes(4).toString('base64');
  };
  
  const hashServerSeed = function (serverSeed) {
      const hash = crypto.createHash('sha512');
      hash.update(serverSeed);
      return hash.digest('hex');
  };
  
  module.exports = {
      hashServerSeed,
      generateServerSeed
  };
  </code></pre>
  
  <p>This is the function, where this module is used:</p>
  
  <pre><code>// blabla.js
  import { generateServerSeed, hashServerSeed } from './seeds';
  
  const VeryImportantFunction = () =&gt; {
      const serverSeed = generateServerSeed();
      const hash = hashServerSeed(serverSeed);
      return hash;
  };
  
  module.exports = {
      VeryImportantFunction
  };
  </code></pre>
  
  <p>and this is my test file</p>
  
  <pre><code>jest.mock('../seeds');
  import { VeryImportantFunction } from '../blabla';
  import { generateServerSeed } from '../seeds';
  const { hashServerSeed } = jest.requireActual('../seeds');
  
  describe('Playground', function () {
      test('blabla', () =&gt; {
          generateServerSeed.mockReturnValue('1234567890ABCDEF');
          expect(VeryImportantFunction()).toBe('f456e02c19ac920...c630bd36cf04b4f57');
      });
  });
  </code></pre>
  
  <p>Above I've tried to mock <code>generateServerSeed</code>, which is ok. But I was not able to find how to leave the original implementation of <code>hashServerSeed</code> using <code>jest.requireActual</code>, because in the test function itself I am not explicitly calling that function.</p>
  
  <p>How can I leave <code>hashServerSeed</code>'s original implementation and mock only <code>generateServerSeed</code> while NOT separating these 2 functions and not using manual mock to keep in simple.</p>