When you need to assert how many elements were found, it is more readable and easier when you do it using count()
:
expect(element.all(by.repeater('product in products')).count()).toBeGreaterThan(1);
instead of resolving the ElementArrayFinder
value and getting the .length
property:
element.all(by.repeater('product in products')).then(function (products) {
expect(products.length >= 1).toBeTruthy();
});
👎 Any use of the following patterns are considered warnings:
element.all(by.repeater('product in products')).then(function (products) {
expect(products.length >= 1).toBeTruthy();
});
element.all(by.repeater('product in products')).then(function (products) {
expect(10).toEqual(products.length);
});
👍 The following patterns are not warnings:
expect(element.all(by.repeater('product in products')).count()).toBeGreaterThan(1);
var products = [];
console.log(products.length);
element.all(by.repeater('product in products')).then(function (products) {
console.log('test');
});