语法格式:
.should(chainers)
.should(chainers, value)
.should(chainers, method, value)
.should(callbackFn)
注意:Chainer可以来自 Chai or Chai-jQuery or Sinon-Chai.
常见断言
长度断言
cy.get('li.selected').should('have.length',3)
类断言
cy.get('form').find('input').should('not.hava.class','disabled')
值断言
cy.get('textarea').should('have.value','poloyy')
文本内容
cy.get('a').parent('span.help').should('not.contain','click me')
元素是否可见
cy.get('button').should('be.visible')
元素是否存在
cy.get('#loading').should('not.exist')
元素状态
cy.get(':radio').should('be.checked')
针对css
cy.get('.completed').should('have.css','text-decoration','line-through')