New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for waiting on the Nth request/response in cy.intercept() #7663
Comments
Existing discussions on this behavior: |
Hi! This feature could potentially resolve our issue #14703 - !! if it would also include the possibility to select not just a specific n-th call from the start, but also the LAST one (e.g. by passing n=-1) |
The ability to get the last one seems likely to cause subtle bugs. How do you know there isn't another request about to come through and how do you know that one isn't the one the developer wanted? Unless you can guarantee that the request you want has already happened you can't feasible get the "last" request and know its what you're after. It seems extremely likely that people will use that incorrectly. At least Nth request is far more likely to be deterministic. |
@thor84no I believe waiting on the last request is the more realistic scenario. It would be like:
|
@mohamedatef2020 but how could Cypress possibly know that it's actually the last request? It can't. You have to tell it how many requests there will be and it then has to wait for the nth request. At any given moment the most recent request is the last request with a possibility of a "last" request coming soon. That never changes. If you look at what I responded to that post suggested using I.e. your example is repeatedly wait for one more request, not wait for the last request. |
@thor84no I agree with you on that. I meant to mention latest request not last. |
Current behavior:
cy.route
has (undocumented) support for waiting on the Nth request/response:cy.route2
does not have this.Desired behavior:
Implement this in
cy.route2
, so that the following tests can pass:cypress/packages/driver/test/cypress/integration/commands/net_stubbing_spec.ts
Lines 991 to 1030 in 1b472e0
Depends on #687
The text was updated successfully, but these errors were encountered: