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

Generic for cy.request response body #9109

Closed
dimazuien opened this issue Nov 5, 2020 · 4 comments · Fixed by #16743
Closed

Generic for cy.request response body #9109

dimazuien opened this issue Nov 5, 2020 · 4 comments · Fixed by #16743
Assignees
Labels
type: typings Issue related to Cypress types (for TypeScript)

Comments

@dimazuien
Copy link

Having a type of response body would be more convenient for TypeScript users

Currently, I see that request and response type annotations look like

request(url: string, body?: RequestBody): Chainable<Response>

interface Response {
  allRequestResponses: any[]
  body: any
  duration: number
  headers: { [key: string]: string }
  isOkStatusCode: boolean
  redirectedToUrl: string
  requestHeaders: { [key: string]: string }
  status: number
  statusText: string
}

If we change it to

request<T = any>(url: string, body?: RequestBody): Chainable<Response<T>>

interface Response<T = any> {
  allRequestResponses: any[]
  body: T
  duration: number
  headers: { [key: string]: string }
  isOkStatusCode: boolean
  redirectedToUrl: string
  requestHeaders: { [key: string]: string }
  status: number
  statusText: string
}

then a user will be able to specify the response body type in their code.

@jennifer-shehane jennifer-shehane added the type: typings Issue related to Cypress types (for TypeScript) label Nov 6, 2020
@jennifer-shehane
Copy link
Member

We would be open to reviewing any Pull Requests made trying to improve the typings. Check out our contributing doc.

@cypress-bot cypress-bot bot added the stage: ready for work The issue is reproducible and in scope label Nov 6, 2020
@cypress-bot cypress-bot bot added stage: work in progress There is an open PR for this issue [WIP] and removed stage: ready for work The issue is reproducible and in scope labels Nov 10, 2020
@dimazuien
Copy link
Author

@jennifer-shehane, could you take a look at PR and let me know if there's anything else you need

@cypress-bot cypress-bot bot added stage: icebox and removed stage: work in progress There is an open PR for this issue [WIP] labels May 25, 2021
@cypress-bot cypress-bot bot added stage: work in progress There is an open PR for this issue [WIP] stage: needs review The PR code is done & tested, needs review and removed stage: icebox stage: work in progress There is an open PR for this issue [WIP] labels May 31, 2021
@cypress-bot cypress-bot bot added the stage: pending release There is a closed PR for this issue label Jun 2, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 2, 2021

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

@cypress-bot cypress-bot bot removed the stage: needs review The PR code is done & tested, needs review label Jun 2, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 7, 2021

Released in 7.5.0.

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

@cypress-bot cypress-bot bot removed the stage: pending release There is a closed PR for this issue label Jun 7, 2021
@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Jun 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: typings Issue related to Cypress types (for TypeScript)
Projects
None yet
3 participants