And it works. The problem is that “become” (this seems to be a chai-as-promised addition) is equivalent to “deep.equal” and i would like to test with simple equality or contains
Then i get TypeError: Object #<WebdriverIO> has no method 'indexOf'
I don’t understand why i get the webdriver object (to chain webdriver commands i suppose) and not the text content, and then how become works in the first place.
Promises can be a bit perplexing! WebdriverIO transfers its promisness to ChaiAsPromised which decorates the responses with Chai’s Should assertion library. (That’s a bit if a mouthful!)
The normal Chai syntax is to just use should.equal or should.contain. When you want to assert on a callback, you use should.eventually.equal' andshould.eventually.contain`
should.become is shorthand for `should eventually.equal’. I think I’ll remove it from the examples as it has confused a few people. I’ll just stick to the full expressive form
Thank you for your answers.
I can’t try them now since i’m not in front of my dev computer, but i’m 90% sure that i have tried should.eventually.equal but that wasn’t working either.
According to chai.as.promised doc, should.eventually.become is equivalent to should.eventually.deep.equal
The problem is that in my test getText("#login-name-link").should.become("doctoruser") (without the eventually !) was working so why doesn’t should.eventually.equal work ?