interactors
interactors copied to clipboard
Use `cy.should` for the assertions
In Cypress there is cy.should command https://docs.cypress.io/api/commands/should that created especially to make assertions. Currently, we execute all interactions in cy.then context. So technically it doesn't matter how to write tests:
cy.do([
TextField('User name').fillIn('John Foo'),
Checkbox('Remember me').is({ checked: true }),
Button('Submit').click()
])
Or
cy.expect([
TextField('User name').fillIn('John Foo'),
Checkbox('Remember me').is({ checked: true }),
Button('Submit').click()
])
Or
cy.do(TextField('User name').fillIn('John Foo'))
cy.expect(Checkbox('Remember me').is({ checked: true }))
cy.do(Button('Submit').click())
All of them become like this:
cy.then(() => TextField('User name').fillIn('John Foo'))
cy.then(() => Checkbox('Remember me').is({ checked: true }))
cy.then(() => Button('Submit').click())
And also I think, there is no reason to check the runner state and restrict calling actions after assertions. Because users always will have a workaround to do it.