'Can a component be found using its key?

Does Vue test-utils support looking for components in a list using their key? If not is there other ways of looking for components that are generated in the form of a list in vue?



Solution 1:[1]

You can't query a component using the key in the findComponent() method.

But you can fetch all components within your list, and then filter them like a regular array. Just provide the right condition to find the item you want (usings its props, attrs or whatever)

const items = wrapper.findAllComponents(MyListItem)
const foundItem = items.wrappers.find(listItem => list.props('id') === 'theIdILookFor')

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 kissu