admin管理员组文章数量:1317123
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);
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);
Share
Improve this question
asked Apr 24, 2015 at 9:21
ProGMProGM
7,1084 gold badges35 silver badges54 bronze badges
1
-
Why can't you count
topics
length? – YD1m Commented Apr 24, 2015 at 9:31
2 Answers
Reset to default 5It 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);
});
While the accepted answer works, it can now be done a lot easier. You can just do:
expect(element.all(by.repeater('topic in topics')).count()).toBeGreaterThan(1);
本文标签: javascriptTesting element count inside an ngrepeat with protractorStack Overflow
版权声明:本文标题:javascript - Testing element count inside an ng-repeat with protractor - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742020792a2414631.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论