-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Typings for cy.route inconsistent with documentation #1831
Comments
Sorry, could you be more specific about where exactly the docs/typings differ? Is there an error when you run the code above? |
The typescript compiler has an error, and thus there's an error reflected in the IDE. I can get around this by ignoring it or typecasting around, but the point is that it's wrong unless the function isn't meant to be used in the way the docs specify. There error I get in Cypress (but this just comes from the typescript preprocessor): const campaignResponse = {...}
cy.route("POST", /twreceiver/, campaignResponse).as("campaignResponse") [tsl] ERROR in /Users/rsmith/project/specs/test.spec.ts(61,40)
TS2345: Argument of type '{ campaignResponses: { campaignName: string; messages: { promotedItems: { type: string; name: str...' is not assignable to parameter of type 'string | Response'.
Type '{ campaignResponses: { campaignName: string; messages: { promotedItems: { type: string; name: str...' is not assignable to type 'Response'.
Property 'allRequestResponses' is missing in type '{ campaignResponses: { campaignName: string; messages: { promotedItems: { type: string; name: str...'. |
Hmm, I have to look at this, probably missing "partial" |
@bahmutov IMO it is not missing cy.server()
cy.route('https://localhost:7777/users', [{id: 1, name: 'Pat'}]) Therefore I believe the typings should look something like this: route(url: string | RegExp, response?: string | Response | object /* or any or unknown in TS 3.0 */): Chainable<null>
route(method: string, url: string | RegExp, response?: string | Response | object /* or any or unknown in TS 3.0 */): Chainable<null>
route(fn: () => RouteOptions): Chainable<null>
route(options: Partial<RouteOptions>): Chainable<null> Also, maybe the |
Is this a Feature or Bug?
(documentation) bug
Current behavior:
Docs (or typings) are wrong
Desired behavior:
Both should be consistent
Steps to reproduce:
The docs for
cy.route
with stubbing are inconsistent with the typings published with cypress. Examples:Docs:
And the typings for cy.route:
Also, it seems that Cypress.Response isn't really want is specified in the docs. At least, if this is what's required, a bunch of props that probably shouldn't be necessary for this are required.
Versions
Cypress 3.0.0
The text was updated successfully, but these errors were encountered: