1

I am using bellow mentioned code to compare multiple values with one expected values and if the text matches with anyone of them my test should pass :

Promise.all([Summ,Desc,Comment]).then(function(values){
    console.log("values = " +values);
    expect(values[0]||values[1]||values[2]).toMatch('searchtxt');
});

But with this code it always try to match first (values[0]), if this does not match then my test will fail.

How can I change it so that protractor looks for all 3 values and then if anyone of them matches my test should pass.

alecxe
  • 414,977
  • 106
  • 935
  • 1,083
ssharma
  • 895
  • 1
  • 17
  • 37

2 Answers2

1

if anyone of them matches my test should pass

In this case, you don't need anything special, just concatenate the values:

expect(values[0] + values[1] + values[2]).toMatch('searchtxt');

Please also see the follow-up to your problem here:

Community
  • 1
  • 1
alecxe
  • 414,977
  • 106
  • 935
  • 1,083
0

Try this,

expect(values[0] == searchtxt || values[1] == searchtxt || values[2] == searchtxt).toEqual(true);
Koga
  • 722
  • 5
  • 15