I am new to Jest Unit testing. I need to write a test case for a React functional Component. Below is the code snippet for API call
useEffect(() => {
getInitialData(props.id, props.baseUrl).then((response: any) => {
setInitialResponse(response.initialResponse);
if (props.initialData) props.initialData(response.initialResponse);
setLoader(false);
});
}, []);
I don't know how to cover these lines in the jest test case. Passing id and baseUrl to this component, not covering lines after 'then'. I don't know How can I mock this also as it is present inside useEffect.