I've got a React custom hook that tries to avoid repeated calls to a URL. This is done by storing in state the isLoading
prop, which is set to true
whenever the fetch method is called, and is set to false
once it receives the response from the server.
To test it, I need to be able to count how many times 'fetch' has been called, but I cannot seem to find any option or property or method inside nock
library that gets me that.
There is a isDone
method to know if all mocks have been fulfilled. There is a pendingMocks
to know how many mocks haven't been fulfilled. But I can't find a way to count how many times fetch
has been called, without caring about anything else (just the URL match).
They may be 100 times or just 2, just want to check how many times fetch
has been called, just like toHaveFetchedTimes
in fetch-mock-jest
. Is there any way to do so in nock
?