lundi 20 juin 2016

One of strings in array to match an expression

The Problem:

I have a promise which is resolved to an array of strings. Now the test should pass if at least one of the strings matches a regular expression.

Currently, I solve it using simple string concatenation:

protractor.promise.all([text1, text2, text3]).then(function (values) {
    expect(values[0] + values[1] + values[2]).toMatch(/expression/);
});

Obviously, this does not scale well and is not particularly readable.

The Question:

Is is possible to solve it using a custom jasmine matcher, or jasmine.any() or custom asymmetric equality tester?

Aucun commentaire:

Enregistrer un commentaire