Troubles with cucumber chai syntax

Hi,
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:

this.client.waitForVisible("#login-name-link").getText("#login-name-link").
  should.become("doctoruser").and.notify(callback);

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 :

this.client.waitForVisible("#login-name-link").getText("#login-name-link").
  should.containsText("doctoruser").and.notify(callback);

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

I have tried :

this.client.waitForVisible("#login-name-link").getText("#login-name-link").
  should.contain("doctoruser").and.notify(callback);

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?

this.client.waitForVisible("#login-name-link").getText("#login-name-link").should.eventually.equal("doctoruser").and.notify(callback);

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.eventually.containText

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 ?

I will try that tonight and get back at you.

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