Reputation: 4680
Following this example I can get tests working with the expect syntax but not with the should syntax.
The following works:
var expect = chai.expect;
describe('expect syntax', function() {
it('should work', function() {
...
expect(promise).to.eventually.eql('something');
});
});
But this does not:
chai.should();
describe('should syntax', function() {
it('should work', function() {
...
(true).should.be.true;
promise.should.eventually.eql('something');
});
});
Since I get the following error: TypeError: Cannot read property 'eventually' of undefined
I assume that should does its usual thing of extending the Object prototype but this somehow doesn't apply to the webdriver promise Object. What is wrong here?
Upvotes: 2
Views: 3428
Reputation: 4680
Following my issue and this other issue that I somehow missed, it would appear that the source of the problem is that webdriverjs promises are based on promise/A and promise/B while chai-as-expected is expecting promise/A+ types promises.
Wrapping the websriverjs promise in a Q promise solved the issue:
Q(webdriverjspromise).should.eventually.eql('something')
Upvotes: 2
Reputation: 4702
This works for us..
var element = $('#mainDiv');
expect(element.isEnabled()).to.eventually.to.equal(true, "Expect Button to be enabled.");
I'd make sure that the "promise' is really a promise, and does eql work? I've always used equal.
On a side note we're using Cucumber with Chai & Chai-as-promised but it shouldn't matter with the promise.
Upvotes: 0