Cypress辅助测试动态网络应用的核心特性即是retry-ability。就像坐在通畅的交通工具上行动一样,我们很难感知到它(retry-ability)。但是了解retry-ability如何工作有利于我们写出更快的测试。
Commands和Assertions
Cypress测试中主要有两种方法:Commands和Assertions,举例:
it('creates 2 items', () => {
cy.visit('/') // command
cy.focused() // command
.should('have.class', 'new-todo') // assertion
cy.get('.new-todo') // command
.type('todo A{enter}') // command
.type('todo B{enter}') // command
cy.get('.todo-list li') // command
.should('have.length', 2) // assertion
})
网友评论