Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple matches in shouldHave({ text: ... }) #23

Open
joshski opened this issue Jan 27, 2016 · 1 comment
Open

Multiple matches in shouldHave({ text: ... }) #23

joshski opened this issue Jan 27, 2016 · 1 comment

Comments

@joshski
Copy link
Member

joshski commented Jan 27, 2016

It wasn't clear to me what this means exactly:

component.shouldHave({ text: ['a', 'b'] });

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:

Promise.all(errors.map(function(error) {
   return myPage.shouldHave({ text: error });
})

Is there a neater way to do this?

It strikes me that an alternative shouldHave({ text: [] }); could do this instead:

1. Get the concatenated text of all elements matched by the component.
2. Check if each string in the array is a substring.
@dereke
Copy link
Member

dereke commented Apr 3, 2017

@refractalize what are your thoughts on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants