Cypress objects/variables Aliases cannot be accessed using the this
keyword
#22294
-
After reading this doc https://docs.cypress.io/guides/core-concepts/variables-and-aliases#Sharing-Context I've tried to do this:
Same thing for:
I've tried also with passing objects / arrays, same thing of course, but with no success. Any ideas why this is failing? |
Beta Was this translation helpful? Give feedback.
Answered by
jjhelguero
Jun 15, 2022
Replies: 1 comment 1 reply
-
In order to use the describe("tests", () => {
beforeEach("beforeach", () => {
cy.visit("https://www.google.com/");
cy.wrap("one").as("miNumero");
});
it("test 1", function() {
expect(this.miNumero).to.equal("one");
});
}); |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
jgonzalezalbisu
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In order to use the
this
keyword, you'll have to usefunction() {...}
callbacks. The docs explain more about it.