Skip to content

Commit

Permalink
fix: rethrow if the Chai property is invalid, closes #36
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Oct 3, 2022
1 parent 792c3c2 commit 0bc8f59
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
31 changes: 31 additions & 0 deletions cypress/e2e/alias.cy.js
@@ -0,0 +1,31 @@
/// <reference types="cypress" />
// @ts-check

import '../../src'

describe('aliases', () => {
it('has an existing alias', () => {
cy.wrap(42).as('answer')
cy.get('@answer')
.if('exist')
.log('alias exists')
.then(cy.spy().as('if'))
.else()
.then(cy.spy().as('else'))
cy.get('@if').should('have.been.called')
cy.get('@else').should('not.have.been.called')
})

// SKIP: https://github.com/bahmutov/cypress-if/issues/35
it.skip('has no alias', () => {
// notice there is no alias with the name "answer"
cy.get('@answer')
.if('exist')
.log('alias exists')
.then(cy.spy().as('if'))
.else()
.then(cy.spy().as('else'))
cy.get('@if').should('have.been.called')
cy.get('@else').should('not.have.been.called')
})
})
3 changes: 3 additions & 0 deletions src/index.js
Expand Up @@ -102,6 +102,9 @@ Cypress.Commands.add(
} catch (e) {
console.error(e)
assertionsPassed = false
if (e.message.includes('Invalid Chai property')) {
throw e
}
}
}
}
Expand Down

0 comments on commit 0bc8f59

Please sign in to comment.