From the course: End-to-End JavaScript Testing with Cypress.io
Unlock this course with a free trial
Join today to access over 24,100 courses taught by industry experts.
The wrap command
From the course: End-to-End JavaScript Testing with Cypress.io
The wrap command
- [Instructor] Alright, so now that we've taken a look at a lot of the basics of working with Cypress, we're going to move on to some important commands that I think you'll find helpful in constructing more readable and maintainable tests. So the first command that we're going to talk about is called the wrap command. You'll see what that looks like in just a minute here. But the basic purpose of this command is that it makes it easier to work with elements when we access the sort of intermediate results like what we've done in this results.cy.js file, right? Remember that by calling then and having a callback function, we could actually get access to the element that we were operating on and use that to make sort of a different type of assertion, more chai style assertions than what we would normally do with Cypress. However, that might not always be what you want, and in many cases you'll actually want to work with this element in the same way as you would've been able to work with…