Based on failure messages, I figured it means: the component should match 2 elements, and the text of each element should match the corresponding index in the array. My problem with this behaviour, is that it leads towards more specific assertions than I would like to make. When I want to say "my page should show these messages, but I don't care where", I try this:
myPage.shouldHave({ text: ['must have numbers', 'must not have punctuation'] });
...but that's not quite right, because myPage only matches one element. So I end up doing this:
myPage.find('.errors li').shouldHave({ text: ['must have numbers', 'must not have punctuation'] });
...but now my assertions are more coupled to the structure of the page than I would like. Currently that means I do:
It wasn't clear to me what this means exactly:
Based on failure messages, I figured it means: the component should match 2 elements, and the text of each element should match the corresponding index in the array. My problem with this behaviour, is that it leads towards more specific assertions than I would like to make. When I want to say "my page should show these messages, but I don't care where", I try this:
...but that's not quite right, because
myPage
only matches one element. So I end up doing this:...but now my assertions are more coupled to the structure of the page than I would like. Currently that means I do:
Is there a neater way to do this?
It strikes me that an alternative
shouldHave({ text: [] });
could do this instead: