lundi 18 avril 2016

Is it a way to chaining chai.js's expects in nightwatch

I'm want to use chai.js assertion bdd library with Nightwatch.js.

It's works! My 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 for own methods which make you able to chain methods like browser.setValue('...', '...').click('...').end().

The question: Can I achieve chaining of methods if I'm use chaijs?

Explanation, what I 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 I make my tests to looks like code above?

Aucun commentaire:

Enregistrer un commentaire