One of my test expects an error message text to be one of multiple values. Since getText()
returns a promise I cannot use toContain()
jasmine matcher. The following would not work since protractor
(jasminewd
under-the-hood) would not resolve a promise in the second part of the matcher, toContain()
in this case:
expect(["Unknown Error", "Connection Error"]).toContain(page.errorMessage.getText());
Question: Is there a way to check if an element is in an array with jasmine+protractor where an element is a promise?
In other words, I'm looking for inverse of toContain()
.
As a workaround, I can resolve the promise with then()
:
page.errorMessage.getText().then(function (text) {
expect(["Unknown Error", "Connection Error"]).toContain(text);
});
I'm not sure if this is the best option. I would also be okay with a solution based on third-parties like jasmine-matchers
.
As an example, this kind of assertion exists in Python:
self.assertIn(1, [1, 2, 3, 4])
Aucun commentaire:
Enregistrer un commentaire