Skip to content

Add throttleKbps, delayMs with presets to StaticResponse objects #7661

Closed
@flotwig

Description

@flotwig

Current behavior:

Users have to invoke .delay() or .throttle() to delay/throttle the response, and they have to use plain numbers (ms and kbps, respectively) to set the throttle:

cy.route2('/timeout', (req) => {
req.reply((res) => {
this.start = Date.now()
res.throttle(kbps).delay(delayMs).send({
statusCode: 200,
body: payload,
})
})

Desired behavior:

Users should be able to statically define throttleKbps or delayMs, and should be able to use string presets. So the above code could be written as this:

cy.route2('/timeout', {
	statusCode: 200,
	body: payload,
	delayMs,
	throttle: '3g', 
})

For the list of throttle presets, we can probably use the same list that Chromium/WebKit use: https://source.chromium.org/chromium/chromium/src/+/master:chrome/test/chromedriver/chrome/network_list.cc;l=12;drc=23bc3b1c92fd920d4d359ba46d73054ff0f47d2c?originalUrl=https:%2F%2Fcs.chromium.org%2F

Depends on #687

Activity

cypress-bot

cypress-bot commented on Sep 11, 2020

@cypress-bot
Contributor

The code for this is done in cypress-io/cypress#8109, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

cypress-bot

cypress-bot commented on Sep 15, 2020

@cypress-bot
Contributor

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.

1 remaining item

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

pkg/driverThis is due to an issue in the packages/driver directorytopic: cy.intercept()type: enhancementRequested enhancement of existing feature

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @flotwig@JessicaSachs

    Issue actions

      Add throttleKbps, delayMs with presets to StaticResponse objects · Issue #7661 · cypress-io/cypress