javascript - Is it a way to chaining chai.js's expects in nightwatch -
i'm want use chai.js assertion bdd library nightwatch.js.
it's works! code looks like:
var expect = require('chai').expect module.exports = { 'login' : function (browser) { var login = browser.page.login() login.expect.element('@login').to.not.be.enabled login.setvalue('@email', 'some@some.com') login.setvalue('@password', 'pass') login.expect.element('@login').to.be.enabled login.click('@login') login.end() } }
but. nightwatch provides pretty fluent interface own methods make able chain methods browser.setvalue('...', '...').click('...').end()
.
the question: can achieve chaining of methods if i'm use chaijs?
explanation, want:
module.exports = { 'login' : function (browser) { var login = browser.page.login() login.expect.element('@login').to.not.be.enabled .setvalue('@email', 'some@some.com') .setvalue('@password', 'pass') .expect.element('@login').to.be.enabled .click('@login') .end() } }
can make tests looks code above?
in order use multiple expects have this:
module.exports = { 'login' : function (browser) { var login = browser.page.login() login.expect.element('@login').to.not.be.enabled login .setvalue('@email', 'some@some.com') .setvalue('@password', 'pass') .expect.element('@login').to.be.enabled login .click('@login') .end() } }
this happens when use .expect(...) in test, or in custom functions within page object, have use browser/client/page object var again start chaining again.
Comments
Post a Comment