Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preview Chai.js based expect assertions #456

Merged
merged 3 commits into from Jun 21, 2015
Merged

Conversation

beatfactor
Copy link
Member

This is a preview of the new upcoming assertion library in v0.7 based on Chai.js. It provides a much more flexible syntax and style.

Example:

  client.url('http://google.com')

  client.expect.element('#lst-ib').to.be.enabled;
  client.expect.element('body').to.be.present.before(1000);
  client.expect.element('#lst-ib').to.have.css('display').matches(/block/).before(2000);
  client.expect.element('body').to.have.attribute('class').which.matches(/vasq$/);
  client.expect.element('#hplogo').text.to.match(/Norge/).before(1000);

  client.setValue('#lst-ib', 'Norway').pause(500);
  client.expect.element('#lst-ib').to.have.value.equal('Norway');
  client.expect.element('#lst-ib').to.be.an('input');
  client.expect.element('#lst-ib').to.be.not.selected;
  client.expect.element('#lst-ib').to.be.visible;

  client.end();
};

@beatfactor beatfactor changed the title Chai.js based expect assertions Preview Chai.js based expect assertions May 18, 2015

function Element(selector, using) {
this.selector = selector;
this.locator = using || 'css selector';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity why not check client.locateStrategy here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's on the TODO list :)

@pekeler
Copy link

pekeler commented Jun 19, 2015

FYI: The main reason I picked nightwatch over the alternatives a couple of weeks ago was specifically the lack of any BDD-style API (which is BS, IMO).

@beatfactor
Copy link
Member Author

Well, I can't say I'm a big fan of BDD but this offers much more flexibility and that's quite important.

@beatfactor beatfactor merged commit 398c3ad into master Jun 21, 2015
@beatfactor beatfactor deleted the features/chai-expect branch June 21, 2015 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants