mock-inspect
mock-inspect copied to clipboard
Feature request: expect how many times a request has been made
Currently, we can only check IF a request has been made using expectRequestToHaveBeenMade
and expectRequestNotToHaveBeenMade
. From internal statistics at trayio, these two methods are by far the most popular ones in the library.
Extending on this I think it would be nice to be able to expect how often a request was made. I suggest the following API:
const loginRequest = mockRequest({
requestPattern: "https://www.example.com/login",
requestMethod: "POST",
responseBody: "hereGoesMyAuthToken",
persistent: true
})
loginRequest.expectRequestToHaveBeenMadeTimes(8)
The particularity of this is that this would currently only work if persistent: true
is used. Otherwise, the mock response will only take effect one single time when the request is made.