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.

Common assertions

Common assertions

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

Start my 1-month free trial

Common assertions

- [Instructor] So far in order to make assertions in Cypress. The only assertions we've really used has been should equal. But Cypress provides us with a lot more assertions that we can use to test the behavior of our application. In this video, we're going to take a look at what some of these useful assertions are and in what circumstances we'd use them. Besides should equal one of the most common assertions you'll use is checking how many of a certain element are on a page. And for this we use the should have length assertion, which looks like this. And this is really useful if you have a dynamic list that you want to check. For example, if our app has a to-do list that we can add items to. In this situation if we wanted to check the functionality of adding items to our list, we'd simply tell Cypress to type in several items and click add and then check how many items are actually on the page to see if that matches…

Contents