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

Getting error cy.currentSubject is not a function #21

Closed shash-hegde closed 2 years ago

shash-hegde commented 2 years ago

Getting error cy.currentSubject is not a function on using the cypress if plugin Cypress Version: 9.6.0

Below is the sample code:

    cy.get('div[role="dialog"]')
            .if('visible')
            .then(() => {
                cy.log('closing the dialog');
                cy.contains('button', 'Close').click();
            })
            .else()
            .then(() => {
                cy.log('Already closed');
            });

cypress if

bahmutov commented 2 years ago

Yeah, this is Cypress v10 function. I am not sure if I want to maintain this plugin to be backwards compatible and work in Cypress v9. I will think about it, but if anyone wants to open a PR (has to be testing it too), that would be nice

elainedcb commented 2 years ago

I'm also getting this error in Cypress v10.2.0, is it only for higher v10 versions?

bahmutov commented 2 years ago

Could use v9 testing approach similar to https://github.com/bahmutov/cypress-wait-if-happens/pull/1

github-actions[bot] commented 2 years ago

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

The release is available on:

Your semantic-release bot :package::rocket: