Home  >  Q&A  >  body text

Is it possible to locate a component using its key?

Vue test-utils Does it support finding a component in a list using its key? If not, is there any other way to find components generated as a list in vue?

P粉166779363P粉166779363205 days ago367

reply all(1)I'll reply

  • P粉156415696

    P粉1564156962024-03-28 00:57:35

    You cannot query a component using a key in the findComponent() method.

    But you can get all the components in the list and filter them like a regular array. Just provide the correct criteria to find the item you want (using its props, properties, or other content)

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

    reply
    0
  • Cancelreply