Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use cy.should for the assertions #109

Open
wKich opened this issue Oct 28, 2021 · 0 comments
Open

Use cy.should for the assertions #109

wKich opened this issue Oct 28, 2021 · 0 comments
Labels
question Further information is requested

Comments

@wKich
Copy link
Member

wKich commented Oct 28, 2021

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.

@wKich wKich added the question Further information is requested label Oct 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant