Skip to content

Bug: findAll returns an array of undefined #2003

Open
@thany

Description

@thany

Describe the bug
The findAll function returns an array of the correct amount, but all elements in the array are undefined.

To Reproduce

describe('CompanyDetail', () => {
  it('should render company data', () => {
    const component = mount(CompanyDetail, { /* props */ });

    const labels = component.findAll('labels');
    console.log(labels, labels.length);
    // --> `WrapperArray { selector: 'label' } 18`
    for (let i = 0; i < labels.length; i += 1) {
      console.log(labels[i]);
    }
    // --> `undefined` (repeating 18 times)

    expect(labels[0].text()).toContain('Company name');
    // --> `TypeError: Cannot read properties of undefined (reading 'text')`
  });
});

Expected behavior
Return of findAll should iterate over all found elements, rather than a not-so-useful collection of undefined values.

Related information:

  • @vue/test-utils version: 1.3.0
  • Vue version: 2.6.14
  • node version: 16.17.0
  • npm (or yarn) version: 8.18.0

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