thefrontside / thefrontside/interactors

Use `cy.should` for the assertions

Open
#109 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
TypeScript
Stars
36
Forks
2
Avg merge
4m
Merged PRs (30d)
2

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the issue's examples and the Cypress should documentation, then locate the current implementations of cy.do, cy.expect, and their cy.then behavior. The work is done when assertions use cy.should and the runner no longer restricts actions after assertions, with the existing interaction behavior preserved.

Written by the indexing model from the issue text.

Assessment

Tech stack
cypress, typescript
Domain
testing-qa
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.