Skip to content
This repository has been archived by the owner on Aug 24, 2023. It is now read-only.

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

Open
rickschubert opened this issue Apr 7, 2021 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@rickschubert
Copy link
Contributor

rickschubert commented Apr 7, 2021

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 rickschubert added the enhancement New feature or request label Apr 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant