title: Jest TypeError: fetch is not a function
body: <p>I have the following Jest test code to test a <em>fetch</em> to an <em>endpoint</em>:</p>
  <pre><code>import MovieApiService from 'services/MovieApiService';
  import movies from '../constants/movies';
  
  describe('MovieApiService', () =&gt; {
  
    test('if jest work correctly', () =&gt; {
      expect(true).toBe(true);
    });
  
    test('get an array of popular movies', () =&gt; {
      global.fetch = jest.mock('../mocks/movies');
      const movieApiService = new MovieApiService();
      return movieApiService.getPopularMovies()
        .then(data =&gt; expect(data).toBe(movies));
    });
  });
  </code></pre>
  <p>But I am getting:</p>
  <p><a href="https://i.stack.imgur.com/efjhh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/efjhh.png" alt="Enter image description here" /></a></p>
  <p>I know that the <code>movieApiService.getPopularMovies()</code> is a <em>JavaScript fetch request</em>, but <em>Node.js</em> does not have the fetch API, so how I can I make this test to work using Jest?</p>