14 Cypress Assertions - biswajitsundara/Cypress GitHub Wiki

Cypress uses Chai library for assertions. Below are some commonly used assertions.

Size

Let's say we are validating the number of rows in a table, or number of items under a list.

cy.get('li').should('have.length',3);

Have text

If we want to validate if the element has the text

cy.get('h1.logo-font').should('have.text','conduit');

Visible

We want to check the element is visible before performing the click operation.

cy.get('.btn').contains('Sign in').should('be.visible').click();
⚠️ **GitHub.com Fallback** ⚠️