Transfer Promises
Since v3
of WebdriverIO every command represents a promise. This allows us to introduce some neat
testing features when adding promised based assertion libraries like chai-as-promised.
1 | it('should contain a certain text after clicking', function() { |
The example above shows a simple integration test where a user clicks on a “Send” button and a message gets send. The test checks if a status message gets displayed with a certain text. This already looks pretty straightforward but by adding an assertion library like chai-as-promised we can shorten everything even more.
1 | before(function() { |
Put this somewhere in your test setup (e.g. the before or onPrepare hook). It initialises Chai
as assertion library and hooks up WebdriverIO with chai-as-promised
by setting the transferPromiseness
function to the internal one of WebdriverIO. This allows us to write
super simple assertions like:
1 | it('should contain a certain text after clicking', function() { |