Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add cy.find + cy.if support (#33)
* testing find command * fix: add cy.find command support
- Loading branch information
Showing
3 changed files
with
82 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/// <reference types="cypress" /> | ||
// @ts-check | ||
|
||
import '../../src' | ||
|
||
describe('cy.find', () => { | ||
it('takes the if branch', () => { | ||
cy.visit('cypress/checkbox.html') | ||
cy.get('#app1') | ||
.find('#enrolled') | ||
.if('exist') | ||
.then(cy.spy().as('if')) | ||
.log('checkbox found') | ||
.else() | ||
.log('checkbox not found') | ||
.then(cy.spy().as('else')) | ||
cy.get('@if').should('have.been.called') | ||
cy.get('@else').should('not.have.been.called') | ||
}) | ||
|
||
it('takes the else branch', () => { | ||
cy.visit('cypress/checkbox.html') | ||
// the checkbox should not be checked | ||
cy.get('#enrolled').should('not.be.checked') | ||
|
||
cy.get('#app1') | ||
.find('#enrolled') | ||
.if('checked') | ||
.then(cy.spy().as('if')) | ||
.log('checkbox found') | ||
.else() | ||
.log('checkbox not found') | ||
.then(cy.spy().as('else')) | ||
cy.get('@else').should('have.been.called') | ||
cy.get('@if').should('not.have.been.called') | ||
}) | ||
|
||
// https://github.com/bahmutov/cypress-if/issues/32 | ||
it('checks if the element exists (it does not)', () => { | ||
cy.visit('cypress/checkbox.html') | ||
cy.get('#app1') | ||
.find('#doest-not-exist') | ||
.if('exist') | ||
.then(cy.spy().as('if')) | ||
.log('checkbox found') | ||
.else() | ||
.log('checkbox not found') | ||
.then(cy.spy().as('else')) | ||
cy.get('@else').should('have.been.called') | ||
cy.get('@if').should('not.have.been.called') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters