-
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
Property 'request' does not exist on type 'HTMLElement'. during request aliasing #24823
Comments
After some research by my collegue it should be |
@CSchulz thank you for reporting this Typescript issue. It looks like we have programmed our types for Is this something you would be interested in contributing? For the time being, you could override this type locally to get around this error. // load the global Cypress types
/// <reference types="cypress" />
declare namespace Cypress {
type AliasSelector = `@${string}`
interface Chainable {
/**
* Custom command to select DOM element by data-cy attribute.
* @example cy.dataCy('greeting')
*/
get(alias: AliasSelector): Chainable<any>
}
}
it('issue 24823', () => {
cy.request('https://jsonplaceholder.cypress.io/comments').as('comments')
cy.get('@comments')
.should((response: Cypress.Response<any>) => {
if (response.status === 200) {
expect(response).to.have.property('duration')
} else {
// whatever you want to check here
}
})
}) |
Hi @emilyrohrbough, I am experiencing the same issue. |
This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided. |
This issue still exists in Cypress 14 |
Current behavior
cy.get with an alias for requests returns a JQuery instead of a http response interface.
There was also no notice in the change log about a behavior change.
Desired behavior
cy.get should return Cypress.Response type to enable response status checks and similar like in the code example.
Test code to reproduce
https://docs.cypress.io/guides/core-concepts/variables-and-aliases#Requests
Cypress Version
11.2.0
Node version
16.15.0
Operating System
Windows 10
Debug Logs
No response
Other
No response
The text was updated successfully, but these errors were encountered: