Vue-test-utils: findAllComponents() is not a proper substitute for findAll()

Created on 24 Jun 2020  路  4Comments  路  Source: vuejs/vue-test-utils

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.

Most helpful comment

Hi!

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

All 4 comments

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!

@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.

Hi!

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

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.

Was this page helpful?
0 / 5 - 0 ratings