-
Notifications
You must be signed in to change notification settings - Fork 267
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
findAll
returns the parent node in the result set if it matches the selector when chained from get
To Reproduce
ParentComponent.vue
<template>
<div class="parent">
<div>child</div>
<div>child</div>
<div>child</div>
</div>
</template>
ParentComponent.spec.js
import { mount } from '@vue/test-utils';
import ParentComponent from '../ParentComponent';
describe('parent', () => {
test('finds 3 children', () => {
const wrapper = mount(ParentComponent);
const parent = wrapper.get('.parent');
expect(parent.findAll('div').length).toBe(3);
});
});
result
parent
✕ finds 3 children (21 ms)
● parent › finds 3 children
expect(received).toBe(expected) // Object.is equality
Expected: 3
Received: 4
Expected behavior
findAll
returns only the 3 child nodes in the result array. This is the behaviour of vue-test-utils@1
Related information:
@vue/test-utils
version:2.0.0-rc.18
Vue
version:3.2.26
node
version:16.13.1
npm
(oryarn
) version:[email protected]
Additional context
I'm aware of the open PR reworking find
and findAll
, as well as a few mentions in other issues relating to findAll
of a contributor currently working on changes to findAll
. Maybe the open PR or the work in progress fixes this, but I thought it was worth documenting.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working