mock-inspect icon indicating copy to clipboard operation
mock-inspect copied to clipboard

Feature request: expect how many times a request has been made

Open rickschubert opened this issue 3 years ago • 0 comments

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.

rickschubert avatar Apr 07 '21 15:04 rickschubert