bahmutov / cypress-if

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

Error after migration to Cy 12 and cucumber preprocessor #73

Open KaiWissel opened 11 months ago

KaiWissel commented 11 months ago

Hi @bahmutov First of all thanks for all your amazing work :-)

After updating several dependencies I receive an error that the element in the else-case can't be found. Switching only Cypress back to the old version works.

We are testing an legacy AngularJS Application... Yeah... I know... 🙈 We also use the Cucumber-Preprocessor within this project.

Old: "@badeball/cypress-cucumber-preprocessor": "^16.0.1", "@bahmutov/cypress-esbuild-preprocessor": "^2.2.0", "cypress": "^11.2.0", "cypress-if": "^1.10.5", "esbuild": "^0.17.11", "eslint": "^8.32.0", "eslint-config-prettier": "^8.6.0", "eslint-plugin-cypress": "^2.12.1", "eslint-plugin-prettier": "^4.2.1", "prettier": "^2.8.3"

New: "@badeball/cypress-cucumber-preprocessor": "^19.2.0", "@bahmutov/cypress-esbuild-preprocessor": "^2.2.0", "cypress": "12.17.3", "cypress-if": "^1.10.5", "cypress-slow-down": "^1.3.1", "esbuild": "^0.19.8", "eslint": "^8.54.0", "eslint-config-prettier": "^9.0.0", "eslint-plugin-cypress": "^2.15.1", "eslint-plugin-prettier": "^5.0.1", "prettier": "^3.1.0"

I use cypress-if as follows

 cy.get(".a-class a")
    .if("visible")
    .contains(option)
    .click()
    .else()
    .then(() => cy.get(".in-some-cases-the-class-changes a").contains(option).click());

With the previous combination this works for our situation. But afer updating I recevice the error message

34
get .a-class a:visible // The initial cy.get retrieves 0 elements
35
assert expected undefined to be visible // Error on the If-Check
36
get in-some-cases-the-class-changes a // Error on the cy.get in the else case

AssertionError
Timed out retrying after 4000ms: Expected to find element: in-some-cases-the-class-changes a, but never found it.
bahmutov commented 8 months ago

Can you give me a small repo with a reproducible example?

KaiWissel commented 8 months ago

Hi Gleb, unfortunately no. I don't work anymore on the project and don't have access to it.

If noone else has this problem, we can close this issue. Thanks for looking into it.