From ae794d1f8c2b68ed63ce2b9fff5fb5160d9ad74b Mon Sep 17 00:00:00 2001 From: Heather Roberts Date: Mon, 26 Mar 2018 01:55:54 +1100 Subject: [PATCH] Issue 831 (#1480) * Check actual is not null or undefined rather than a falsy value This fixes an issue when checking if actual was an empty string * Add test to check empty string attributes are handled as expected --- packages/driver/src/cypress/chai_jquery.coffee | 2 +- .../integration/commands/assertions_spec.coffee | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) 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) =>