Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Stuff to know about Cypress

Assertions

As mentioned in Introduction to Cypress:

What makes Cypress unique from other testing tools is that commands automatically retry their assertions. In fact, they will look “downstream” at what you’re expressing and modify their behavior to make your assertions pass.

Most examples from their documentation rely on their own should() assertion method, which can be called on DOM references returned by cy.get().

E.g. cy.get('button').click().should('have.class', 'active')

As explained there, Cypress supports the following ways to express assertions:

  • Chai BDD; (e.g. expect(name).to.not.equal('Jane'))
  • Chai TDD; (e.g. assert.notEqual(3, 4, 'vals not equal'))
  • chai-jquery; (e.g. expect($el).to.have.attr('foo', 'bar'))
  • and sinon-chai. (e.g. expect(spy).to.be.calledTwice)

Some methods return jQuery objects. In that case, please refer to the jQuery API reference documentation.

To be continued...