Troubles with cucumber chai syntax

as i’m trying to convert my nightwatch tests to cucumber, i have trouble finding the right syntax.
With the example provided i can do that:


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

I have tried :


However i get TypeError: Object [object Object] has no method 'containsText'

I have tried :


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.

Thank you for your help.

How about this?


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`

Try as @mgrahame said:


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 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 ?

I will try that tonight and get back at you.

Ok, this is working with should.eventually.contain . Thank you.