-
-
Notifications
You must be signed in to change notification settings - Fork 53
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
Support for array matchers, similar like the some
method, but for use with expect
#512
Comments
@dietergeerts can you provide an example? |
I have written the following helper:
And used it like:
So basically, the methods that work on a single element, like |
How do you think these matchers should be named? |
🤔 , when we compare with
Because webdriver-io itself doesn't have functions for getting the selection state of all elements, we could also expose such helpers like I don't have too much experience with webdriver-io, so I might be missing things, not seeing existing ways of doing this easily, but also not knowing all (edge-)cases that can happen with element arrays. I've used protractor for years, and it's the first project I'm really using webdriver-io for end-2-end testing now. |
How about we modify matchers such as // checks if a single element is selected
expect($('#singleElem')).toBeSelected()
// checks if all elements are selected
expect($$('.manyElems')).toBeSelected() To enable the other use case of checking if just some are selected we could use a // this would be the same as "expect($('#singleElem')).toBeSelected()"
expect($('#singleElem')).toBeSelected({partial: true})
// checks if at least one element is selected
expect($$('.manyElems')).toBeSelected({partial: true}) This way we can re-use existing matchers and don't bloat the API. What do you think? |
It wouldn't be bloat, unless you think of bloat as just more matchers. Imho, it's better to have more matchers if they make things more clear than having less matchers where there can be confusion in what they can handle. I understand that this can be seen as "taste", but from experience, I have seen that having clear functions(/matchers in this case), where there is only 1 thing they do with 1 way to call them, is the best way to go for everyone, as they are very clear. This is also what Functional Programming is partly about. So whatever you want to choose, this is my preference and experience. |
@webdriverio/project-committers and @mgrybyk any suggestions? |
I agree with Christian that having a single and easy to understand API makes more sense here. Imagine that we would allow you to retrieve the text of all elements. |
I agree too, but sometimes you have something in-between. |
This would be awesome, so that we don't need to apply multiple transformations and calculations, and having no good error feedback when the expect fails.
The text was updated successfully, but these errors were encountered: