0

I use cucumber and chai-as-promised as assertion library. What is the right way to check the count value. I use equal but it works only after converting string to integer.Is there a way to assert a integer value directly?

this.Then(/^the list should contain "([^"]*)" items$/, function (arg1, callback) {
       var count=parseInt(arg1);
      expect(element.all(by.repeater('item in list.items')).count()).to.eventually.equal(count).and.notify(callback);

  });
meteor
  • 2,518
  • 4
  • 38
  • 52

1 Answers1

0

If you really wanted to, I believe you could bypass parseInt() by using Chai's satisfy() method and JavaScript coercion, as shown below. However, I personally prefer the method you are currently using as it is easier to understand and coercion can be tricky.

this.Then(/^the list should contain "([^"]*)" items$/, function (arg1, callback) {
  expect(element.all(by.repeater('item in list.items')).count()).to.eventually.satisfy(function(count) { return count == arg1 } ).and.notify(callback);
});
Nathan Thompson
  • 2,354
  • 1
  • 23
  • 28