From the course: End-to-End JavaScript Testing with Cypress.io

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

The "and" command

The "and" command

From the course: End-to-End JavaScript Testing with Cypress.io

Start my 1-month free trial

The "and" command

- [Instructor] Now there are some commands in Cypress that provide a specific piece of functionality that we can't really access in any other way. And this is true for the majority of the Cypress commands that we've seen so far. But then there are also some Cypress commands that exist almost exclusively for the sake of readability. And one of these commands is the and command. So what the and command is is this. Let's say that we've selected an element in Cypress. I want to make more than one assertion about it. So for example, we might want to check not only that an element has the right text, but also that it has the right class or something else like that. And to make multiple assertions like that we can use two separate should commands. Or instead of using multiple shoulds, we can simply use and for the second one. And again, this is really just a readability thing. I personally find it a little nicer to read this like…

Contents