Assertions

Learn about Cypress Assertions in this lesson.

We'll cover the following...

After you’ve done all the actions, you’re likely going to make some assertions about what’s on the page. Cypress assertions are kind of complicated on one level in that there are a lot of options, but at the same time, the syntax has a couple of common patterns.

You can chain an assertion at the end of a series of commands with should. However, you need to do something between cy and should. You can’t just write cy.should("exist"), but you can write cy.get("selector").should("exist").

The should command typically takes as its first argument, what the Cypress docs call a chainer. Cypress takes its assertions from a library called Chai. Assertions in Chai are a chain of methods, as in to.be.null, or to.have.class or to.be.visible. A Cypress chainer is a string version of everything in the Chai ...