Im unable to mock the handleSuccess function present inside the MyComp. any form of help is much appreciated.
Further : 1) I tried jest.spyon(MyComp,"constructor") to mock the handle success function 2) tried calling the save() by import on the test.spec.js file, the handle success fn did not get trigger even by chance!
import { save } from '.' ;
const MyComp= () => {
const handleSuccess = () => {
// code block
};
const { mutate: data, isLoading } = save({
onSuccess: ({ data }) => {
if (data?.success) handleSuccess();
},
});
return <div>JSX</div>
}
export default MyComp;