bahmutov / cypress-if

Easy conditional if-else logic for your Cypress tests when there is no other way
https://cypress.tips/courses/cypress-plugins
96 stars 12 forks source link

then() chaining not working with else() #59

Closed MRavimoF closed 1 year ago

MRavimoF commented 1 year ago
function bar() {
      return cy.wrap("testing")
      .if()
      .then(() => cy.wrap("got it"))
      .else()
      .then(() => cy.wrap("else do"))
}

bar().then(it => {
      cy.log(`result: ${it}`)
})

Will print

wrap: testing
wrap: got it

I would have expected to see

wrap: testing
wrap: got it
log: result: got it

I get the expected output if I comment out the else branch

function bar() {
      return cy.wrap("testing")
      .if()
      .then(() => cy.wrap("got it"))
//      .else()
//      .then(() => cy.wrap("else do"))
    }

I am a beginner with Cypress and cypress-if, wondering what's up with this behaviour.

"cypress-if": "^1.10.2",
"cypress": "10.11.0",
"cypress-fail-fast": "^3.4.1",
github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 1.10.3 :tada:

The release is available on:

Your semantic-release bot :package::rocket: