-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Subject does not exist assertion (#46)
* add exist spec * fix: handle element not exist assertion
- Loading branch information
Showing
2 changed files
with
86 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/// <reference types="cypress" /> | ||
// @ts-check | ||
|
||
import '../../src' | ||
|
||
beforeEach(() => { | ||
cy.visit('cypress/index.html') | ||
}) | ||
|
||
it('checks an element that exists', () => { | ||
cy.get('#fruits') | ||
.if('exist') | ||
.then(cy.spy().as('if')) | ||
.else() | ||
.then(cy.spy().as('else')) | ||
cy.get('@if').should('have.been.calledOnce') | ||
cy.get('@else').should('not.have.been.called') | ||
}) | ||
|
||
it('checks an element that does not exists', () => { | ||
cy.get('#not-found') | ||
.if('exist') | ||
.then(cy.spy().as('if')) | ||
.else() | ||
.then(cy.spy().as('else')) | ||
cy.get('@else').should('have.been.calledOnce') | ||
cy.get('@if').should('not.have.been.called') | ||
}) | ||
|
||
// https://github.com/bahmutov/cypress-if/issues/45 | ||
it('checks an element that does not exists using not.exist', () => { | ||
cy.get('#not-found').should('not.exist') | ||
cy.get('#not-found') | ||
.if('not.exist') | ||
.then(cy.spy().as('if')) | ||
.else() | ||
.then(cy.spy().as('else')) | ||
cy.get('@if').should('have.been.calledOnce') | ||
cy.get('@else').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