Implicit Assertions


To make an assertion about the current subject, use the .should() command.

  .find('tbody tr:last').should('have.class', 'success')
# Column heading Column heading
1 Column content Column content
2 Column content Column content
3 Column content Column content


To chain multiple assertions together, use the .and() command.

  .should('have.class', 'active')
  .and('have.attr', 'href')
  .and('include', '')

Explicit Assertions


To make an assertion about a specified subject, use expect.

// We can use Chai's BDD style assertions

// Pass a function to should that can have any number
// of explicit assertions within it.
    // return an array of texts from all of the p's
    var texts = $, el){
      return Cypress.$(el).text()

    // jquery map returns jquery object
    // and .get() convert this to simple array
    var texts = texts.get()

    // array should have length of 3

    // set this specific subject
      'Some text from first p',
      'More text from second p',
      'And even more text from third p'

Some text from first p

More text from second p

And even more text from third p