cypress-documentation icon indicating copy to clipboard operation
cypress-documentation copied to clipboard

Example of cy.then() returning synchronous values

Open blue32a opened this issue 3 years ago • 0 comments

Subject

then command

Description

https://docs.cypress.io/api/commands/then#The-number-subject-is-changed-by-returning

cy.wrap(1)
  .then((num) => {
    cy.wrap(num).should('equal', 1) // true

    return 2
  })
  .should('equal', 2) // true

When I try this I get the following error.

cy.then() failed because you are mixing up async and sync code.

Is this example still valid today?

blue32a avatar Jul 25 '22 08:07 blue32a