You have different ways. The first one is resolving the promise returned by protractor and use standard Array
methods, as every
:
// in this case you need to pass next callback in the block and call it after resolving the method for keeping the sync properly and communicate when the
expectation is finished after resolving the promises
this.AllElementsText = element.all(by.css('[style="display: none"]')).getText();
this.AllElementsText.then((texts) => texts.every((text) => (+text) > 30)).then((value) => { expect(value).toBe(true); next(); });
Otherwise you could work with protractor methods like reduce
but being careful to resolving promises (same considerations for the next
callback to be called):
this.AllElementsText = element.all(by.css('[style="display: none"]')).getText();
let baseValue = true;
this.AllElementsText.reduce((acc, text) => baseValue && ((+text) > 30), baseValue).then((value) => { expect(value).toBe(true); next(); })
In both the cases, you can avoid the next
callback returning the promises directly from the expectation blocks.
Be also careful to manage fine all the edge cases, like you don't have texts at all etc...