diff --git a/packages/driver/src/cypress/chai_jquery.coffee b/packages/driver/src/cypress/chai_jquery.coffee index b928471dba..774a5ef9cc 100644 --- a/packages/driver/src/cypress/chai_jquery.coffee +++ b/packages/driver/src/cypress/chai_jquery.coffee @@ -224,7 +224,7 @@ $chaiJquery = (chai, chaiUtils, callbacks = {}) -> assert( @, attr, - actual and actual is val, + actual? and actual is val, message, negatedMessage, val, diff --git a/packages/driver/test/cypress/integration/commands/assertions_spec.coffee b/packages/driver/test/cypress/integration/commands/assertions_spec.coffee index 7c5bb696a1..246d11351c 100644 --- a/packages/driver/test/cypress/integration/commands/assertions_spec.coffee +++ b/packages/driver/test/cypress/integration/commands/assertions_spec.coffee @@ -657,6 +657,18 @@ describe "src/cy/commands/assertions", -> cy.get("body").then ($body) -> expect($body).to.exist + it "matches empty string attributes", (done) -> + cy.on "log:added", (attrs, log) => + if attrs.name is "assert" + cy.removeAllListeners("log:added") + + expect(log.get("message")).to.eq "expected **** to have attribute **value** with the value **''**" + done() + + cy.$$("body").prepend $("") + cy.get("input").eq(0).then ($input) -> + expect($input).to.have.attr('value', '') + describe "without selector", -> it "exists", (done) -> cy.on "log:added", (attrs, log) =>