-
Notifications
You must be signed in to change notification settings - Fork 667
Add a filter method #336
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
Comments
I think if the need and the use case of the feature are not explicitly indicated, |
I have never had any reason to filter on the array returned. Seems like it'll lead to a difficult to read test. If I want to know about a specific element, I use I don't agree with adding a bunch of |
I think @Toilal has a good use case. He wants to filter all the elements that are visible. We're adding a visible method, so the use case would look like this: const wrapperArr = wrapper.findAll('div')
const filteredArr = wrapperArr.filter(w => w.visible()) I can see that being useful |
To better explain my use case, I'm currently writting a Tree component (http://vue-tree.pragmasphere.com/). When clicking on tree node handle, it use Problem is that it's actually very difficult to perform assertion on node visibility because it's not supported by CSS Selectors, and I agree we should have less methods as possible in the Wrapper API, but having both Note that I can't use |
My issue for the |
Currently, WrapperArray is a proxy of array of Wrapper. |
I'm not sure it's technically possible : https://stackoverflow.com/questions/13428189/inherit-from-javascript-array-or-typed-array?lq=1 |
It became possible at ES2015. |
I think if moderate number of people think that they need the |
You can get WrapperArray class from WrapperArray instance. const WrapperArray = wrapperArray.constructor |
Can't say I'm a fan of adding (into core) these thin wrappers on top of what can already be done pretty easily via the contained |
There's a PR open to add a
filter
method tofind
: #334.For example, users could filter elements that are visible:
An alternative would be to make
length
a getter:My preference is to add a
filter
method. What are peoples thoughts?The text was updated successfully, but these errors were encountered: