7

When I tried to verify the condition as below.

 var val1 = "ONE";
 var val2 = "TWO";
 expect(val1==val2).to.eventually.equal(false)

I'm getting false is not a thenable message, If I removed eventually condition as below then it working fine.

 var val1 = "ONE";
 var val2 = "TWO";
 expect(val1==val2).to.equal(false)

Can anyone help me to understand the difference. Also If the condition fails, It displays the error message and not executing the hooks.js.

KAK
  • 905
  • 4
  • 14
  • 33

1 Answers1

13

In simple words:

eventually - is a method from chai-as-promised. If you use eventually protractor expects that you are asserting result of a promise to value (in this case false). val1 and val2 are bools. Comparison of val1 and val2 is also a bool.

Bool is not a promise.

You've got two possibilities: 1. Don't use eventually (just a chai). 2. Return a promise from comparison of those values.

Kacper
  • 1,201
  • 1
  • 9
  • 21
  • Thanks for the info. But one doubt if my bool assertion got failed it throws as error message and abruptly stops the feature file executions without passing the scenarios as failed. – KAK Jul 04 '17 at 14:15
  • Do you use the cucumber framework? I had this problem solved setting ignoreUnhandledExceptions: true in the config file as described here : https://github.com/protractor-cucumber-framework/protractor-cucumber-framework. – Chai Jul 26 '17 at 20:50