Skip to content
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

cy.route2 documentation: delay/throttle function examples not right? #8489

yonigibbs opened this issue Sep 3, 2020 · 2 comments · Fixed by cypress-io/cypress-documentation#3128


Copy link

In the documentation for cy.route2 there's this example of the delay function:

cy.route2('/users', (req) => {

When I tried that I got a compilation error: Property 'delay' does not exist on 'InocmingHttpRequest'. From looking at the code, looks like it's on IncomingHttpResponse, not on the request itself.

Same thing applies to the throttle function. The redirect one does seem to compile OK though.

There's a couple of other minor issues too (let me know if you want separate issues logged for these):

  1. One of the code snippets talks about beetle items in a response - it's not really clear what this is referring to.
  2. The section about multiple requests isn't quite clear in terms of how to stub a single route, and give it a different response every time it's called (particularly required for GraphQL endpoints). For example, can you call cy.route2 multiple times in a test, to set up a different way to handle the call each time?
Copy link

flotwig commented Sep 3, 2020

Yeah, there's a typo, .delay and .throttle should be documented on res, not req.

For example, can you call cy.route2 multiple times in a test, to set up a different way to handle the call each time?

There's not an API for counting requests yet, but you can set up the counting yourself, for example:

let hitCount = 0

cy.route2('/someRoute', (req) => {
	switch (hitCount) {
		case 1: // do something
		case 2: // do something else
		default: // do something for all further requests

Copy link

cypress-bot bot commented Sep 15, 2020

Released in 5.2.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v5.2.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Sep 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

Successfully merging a pull request may close this issue.

2 participants