Expect item in array

后端 未结 3 881
执念已碎
执念已碎 2020-12-04 01:18

One of my test expects an error message text to be one of multiple values. Since getText() returns a promise I cannot use toContain() jasm

3条回答
  •  悲&欢浪女
    2020-12-04 01:54

    The alternative solution is to use .toMatch() matcher with Regular Expressions and specifically a special character | (called "or"), which allows to match only one entry to succeed:

    expect(page.errorMessage.getText()).toMatch(/Unknown Error|Connection Error/);
    

提交回复
热议问题