Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing element count inside an ng-repeat with protractor

I want to test that my ng-repeat generates more than 1 element.

<div ng-repeat="topic in topics">
  <div class="topic-name">{{topic.name}}</div>
</div>

How can I do it? I can't find in the docs...
Is there something like this?

expect(element.all(by.repeater('topic in topics')).count()).toBeMoreThan(1);
like image 468
ProGM Avatar asked Jan 09 '23 12:01

ProGM


1 Answers

It is located in the Jasmine 2.0 docs, here. Try the following code:

var count = element.all(by.repeater('topic in topics'));
count.then(function(result){
    expect(result.length).toBeGreaterThan(1);
});
like image 192
Tom Nijs Avatar answered Jan 11 '23 01:01

Tom Nijs