Skip to content

findAll returns nothing when using a render function #1201

@huuff

Description

@huuff

Subject of the issue

findAll() returns nothing when the component is using a render function.

Steps to reproduce

This as TestComponent.vue:

<template>
<render></render>
</template>

<script setup lang="ts">
import { h } from 'vue';

const render = () => [
  h('a', {}, 'first'),
  h('a', {}, 'second'),
  h('a', {}, 'third'),
];
</script>

Then in TestComponent.spec.ts:

import { mount } from '@vue/test-utils';
import TestComponent from './TestComponent.vue';

describe('mcve', () => {
  test('should have all three anchors', () => {
    const wrapper = mount(TestComponent);

    expect(wrapper.findAll('a').length).toBe(3);
  });
});

Expected behaviour

The test should pass.

Actual behaviour

The test fails because findAll is unable to find the three anchors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions