Uploaded November 2023 | Updated November 2026, 2 days ago
Whenever you get an aliased value using cy.get(alias name) command, it assumes by default that the value is a jQuery object. But if you store an alias to a string, for example, TypeScript will complain:
cy.wrap("hello").as("greeting")
cy.get("@greeting")
// TypeScript thinks you are checking a jQuery object :(
.should("equal", "hello")
This video shows a fix from my course "Testing The Swag Store" https://cypress.tips/courses/swag-store where I declare the type for the yielded value when calling "cy.get". Since YouTube does not allow angular brackets, I will use LT and RT strings
cy.get LT string RT ("@greeting")
// TS knows the current value is a string
.should("equal", "hello")
For more tips, read my blog post "Cypress v10 Tips and Tricks" glebbahmutov.com/blog/cypress-v10-tips
Whenever you get an aliased value using cy.get(alias name) command, it assumes by default that the value is a jQuery object. But if you store an alias to a string, for example, TypeScript will complain:
cy.wrap("hello").as("greeting")
cy.get("@greeting")
// TypeScript thinks you are checking a jQuery object :(
.should("equal", "hello")
This video shows a fix from my course "Testing The Swag Store" https://cypress.tips/courses/swag-store where I declare the type for the yielded value when calling "cy.get". Since YouTube does not allow angular brackets, I will use LT and RT strings
cy.get LT string RT ("@greeting")
// TS knows the current value is a string
.should("equal", "hello")
For more tips, read my blog post "Cypress v10 Tips and Tricks" glebbahmutov.com/blog/cypress-v10-tips








