fix: Cypress.dom.isJquery() returns only boolean results (#14325)

This commit is contained in:
Kukhyeon Heo
2020-12-29 12:04:09 +09:00
committed by GitHub
parent 590dfa486c
commit 6bc3527231
2 changed files with 12 additions and 1 deletions
@@ -9,5 +9,16 @@ describe('src/dom/jquery', () => {
it('is true for actual jquery instances', () => {
expect(Cypress.dom.isJquery(Cypress.$(':first'))).to.be.true
})
// https://github.com/cypress-io/cypress/issues/14278
it('does not return undefined', () => {
cy.visit('fixtures/dom.html')
cy.get('#dom').then(($el) => {
expect(Cypress.dom.isJquery($el[0])).to.eql(false)
// @ts-ignore
expect(Cypress.dom.isJquery()).to.eql(false)
})
})
})
})
+1 -1
View File
@@ -35,7 +35,7 @@ const isJquery = (obj) => {
// as the jquery property of the window constructor
// for actual jquery, it should be the version number
// so we ensure that it is a string (rather than HTML element)
return hasJqueryProperty && typeof _.get(obj, 'constructor.prototype.jquery') === 'string'
return !!hasJqueryProperty && typeof _.get(obj, 'constructor.prototype.jquery') === 'string'
}
// doing a little jiggle wiggle here