Skip to content

findAllComponents() returning the same component twice? #689

Closed
@Giwayume

Description

@Giwayume

Is there a reproduction template for https://codesandbox.io? I'm having trouble finding one.

My component looks something like this:

<template>
    <component1 v-for="item in array" :key="item+ '_item'">
        <component2 data-some-attr="attrvalue" />
    </component1>
</template>
<script>
return {
    data() {
        return {
            array: ['foo']
        };
    }
};
</script>

Test is trying to retrieve all component instances by the custom attribute:

it('test', () => {
    const wrapper = mount(MyComponent);
    const components = wrapper.findAllComponents('[data-some-attr="attrvalue"]');
    expect(components.length).toBe(1);
});

It fails on the length assertion, appears to return the same component twice, even though array controlling the loop has 1 item.

If this problem is not familiar to you, I'd like to know if there's an easy reproduction template so I can sort this out.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions