Skip to content

findAllComponents() is not a proper substitute for findAll() #1594

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

Closed
adama8x opened this issue Jun 24, 2020 · 5 comments
Closed

findAllComponents() is not a proper substitute for findAll() #1594

adama8x opened this issue Jun 24, 2020 · 5 comments

Comments

@adama8x
Copy link

adama8x commented Jun 24, 2020

Feature Description

wrapper.findAllComponents() should Take CSS selectors as an argument.

Well maybe I'm doing something wrong by not throwing refs on every tiny element in my component or making sub components out of every div, but how can I safely test the amount of elements rendered to a list by referencing their class selector when I should not be using the findAll() method anymore?

Am I missing something (which is definitely not unlikely)? If not, this feature would be well appreciated.

Problem

wrapper.findAll() Has a deprecation warning, the suggested substitute wrapper.findAllComponents() does not cover the functionality.

Expected behaviour

As described in the Feature Description

Alternatives

An additional wrapper.findAllElements() function.

@afontcu
Copy link
Member

afontcu commented Jun 24, 2020

Hi! As stated in Update docs, you can use find/findAll on DOM nodes using the querySelector syntax. On the other hand, findComponent and findAllComponents accept a component reference/instance.

So it is likely that findAll would suit your needs.

Hope it helps!

@adama8x
Copy link
Author

adama8x commented Jun 26, 2020

@afontcu thanks for your answer but as I described: "findAll() Has a deprecation warning" (docs), so I would like to avoid using it on new projects.

@afontcu
Copy link
Member

afontcu commented Jun 26, 2020

Hi!

The deprecation warning is only about using findAll to find all Components, not to find all DOM elements.

@adama8x
Copy link
Author

adama8x commented Jun 26, 2020

Well that make sense, I forgot to distinguish between these two, sometimes my brain needs a little kick in in the ass. Thank you for your help.

@RudyOnRails
Copy link

Why do the docs here state that you can pass a selector to findAllComponents?

https://v1.test-utils.vuejs.org/api/wrapper/findallcomponents.html

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

No branches or pull requests

3 participants