i have a function called makeApiRequest, the sole purpose of the function is literally creating REST requests and it is using fetch, I’ve imported this component in many nextjs components like this:
import makeApiRequest from "@/app/helpers/api";
now i want to test those component, i can’t seem to do it properly, since many of my components have multiple useEffects and those useEffects are calling makeApiRequest on mulitple routes, so how can i acheive it? i can’t seem to mock it properly i even read the docs but all they are doing is using spyOn on the classes and then mocking the instances of a class
i was expecting to assert something like
expect(mockMakeApiRequest).toHaveBeenCalled()
or something similar but it’s not even working in my case
Prajwal Negi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.