One of strings in array to match an expression

后端 未结 5 1596
花落未央
花落未央 2021-02-12 22:29

The Problem:

I have an array of promises which is resolved to an array of strings. Now the test should pass if at least one of the strings matc

5条回答
  •  一向
    一向 (楼主)
    2021-02-12 22:59

    Array.prototype.some() looks like what you actually looking for.

    protractor.promise.all([text1, text2, text3]).then(function (values) {
        expect(values.some(v => v.match(/expression/)).toBe(true);
    });
    

    For more information https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/some

提交回复
热议问题