I have the following jest test code to test a fetch to an endpoint:
import MovieApiService from 'services/MovieApiService';
import movies from '../constants/movies';
describe('MovieApiService', () => {
test('if jest work correctly', () => {
expect(true).toBe(true);
});
test('get an array of popular movies', () => {
global.fetch = jest.mock('../mocks/movies');
const movieApiService = new MovieApiService();
return movieApiService.getPopularMovies()
.then(data => expect(data).toBe(movies));
});
});
But I am getting:
I know the movieApiService.getPopularMovies() is a javascript fetch request, but node does not have the fetch api, so how I can I make this test to work using jest
Thanks in advance
Aucun commentaire:
Enregistrer un commentaire