I am calling api in the the react functional component. I am writing unit test cases of the component. I have mocked fetch using jest-fetch-mock.
global.fetch = require('jest-fetch-mock');
Component.ts
const Component = () => {
useEffect(() => {
return fetch(
'url',
)
.then(response => response.json())
.then(json => {
setApiResult(json);
setFilterResult(json?.videos);
})
.catch(error => {
console.error(error);
});
}, []);
}
Does anyone know how to mock the fetch response for this component in jest.