title: How to mock uuid with Jest
body: <p>so on my search for an answer to my problem I found this post: <a href="https://stackoverflow.com/questions/47487766/jest-how-to-globally-mock-node-uuid-or-any-other-imported-module/51382949?noredirect=1#comment89737780_51382949">Jest: How to globally mock node-uuid (or any other imported module)</a></p>
  
  <p>I already tried the answer but I can't seem to use it properly, as it´s giving me an undefined error. I'm new to the testing scene so please excuse any major errors:</p>
  
  <p>This was my first approach</p>
  
  <pre><code>const mockF = jest.mock('uuid'); 
  
  mockF.mockReturnValue('12345789'); 
  </code></pre>
  
  <p>But it wouldn't recognize the functions.</p>
  
  <blockquote>
    <p>"mockF.mockReturnValue is not a function" among others I tried.</p>
  </blockquote>
  
  <p>Then I tried to manually mock as the post suggested but can' seem to make it work, can you help me? Thanks</p>
  
  <p>Here's the entire test if it helps:</p>
  
  <pre><code>    const faker = require('faker');
      const storageUtils = require('../../storage/utils');
      const utils = require('../utils/generateFile');
      const { generateFileName } = storageUtils;
      const { file } = utils;
  
      test('should return a valid file name when provided the correct information', () =&gt; {
          // ARRANGE
          // create a scope
          const scope = {
              type: 'RECRUITER',
              _id: '987654321',
          };
          // establish what the expected name to be returned is
          const expectedName = 'r_987654321_123456789.png';
  
          jest.mock('uuid/v4', () =&gt; () =&gt; '123456789');
  
          // ACTION
          const received = generateFileName(file, scope);
  
          // ASSERT
          // expect the returned value to equal our expected one
          expect(received).toBe(expectedName);
      });
  </code></pre>