question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for waiting on the Nth request/response in cy.intercept()

See original GitHub issue

Current behavior:

cy.route has (undocumented) support for waiting on the Nth request/response:

cy.wait('@foo.1') // first response
cy.wait('@foo.request.1') // first request
cy.wait('@foo.response.5') // fifth response

cy.route2 does not have this.

Desired behavior:

Implement this in cy.route2, so that the following tests can pass:

https://github.com/cypress-io/cypress/blob/1b472e03e56de2de42d8d302009b5e3a1ee35732/packages/driver/test/cypress/integration/commands/net_stubbing_spec.ts#L991-L1030

Depends on #687

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:5
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
quad5commented, Nov 2, 2020

Hi, #687 is now closed. Any chance to get this enhancement ticket on to the implementation queue. This enhancement would help with the issue I reported (#9034). Thanks.

1reaction
thor84nocommented, Mar 9, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

intercept - Cypress Documentation
Waiting on a request. Use cy.wait() with aliasing an intercepted route to wait for the request/response cycle to complete. With URL.
Read more >
How to make Cypress wait for .intercept requests to finish?
Code: describe("Cypress", () => { it("Example Test", () => { cy.intercept("GET", "/api/**").as("getApi"); cy.visit("/home/"); ...
Read more >
Cypress cy.intercept Problems - Gleb Bahmutov
In that case the first cy.wait(alias) "uses up" the intercept's response. Consider the following test that adds a new todo.
Read more >
A Day with Cypress Part 2 - Dragons for Elevenses
Cypress comes with the ability to intercept and replace some requests at test time ... Start up the Cypress routing server with cy.server()...
Read more >
Web automation: Don't use Selenium, use Playwright
Selenium supports things like waiting till an element is clickable? ... I really really like the cy.intercept() for intercepting and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found