-
Notifications
You must be signed in to change notification settings - Fork 272
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Subject of the issue
findComponent don't return expected wrappers
Steps to reproduce
import { mount } from '@vue/test-utils'
describe('A.vue', () => {
test('create', async () => {
const ComponentA = {
name: 'ComponentA',
template: `
<div>
<slot></slot>
</div>
`,
}
const ComponentB = {
name: 'ComponentB',
template: `
<div>
<slot></slot>
</div>
`,
}
const wrapper = mount({
components: {
ComponentA,
ComponentB,
},
template: `
<ComponentA>
<ComponentB>1</ComponentB>
<ComponentB>2</ComponentB>
<ComponentB>3</ComponentB>
</ComponentA>
`,
})
const com1 = wrapper.findComponent(ComponentB)
console.log(com1.html()) // why this wrapper html is `<div>1</div><div>2</div><div>3</div>` ?
const com2 = wrapper.findAllComponents(ComponentB)
console.log(com2[0].html()) // `<div>1</div><div>2</div><div>3</div>`
console.log(com2[1].html()) // `<div>1</div><div>2</div><div>3</div>`
console.log(com2[2].html()) // `<div>1</div><div>2</div><div>3</div>`
})
})
Expected behaviour
com1.html() =>>>> '<div>1</div>'
com2[2].html() =>>>> '<div>3</div>'
Actual behaviour
com1.html() =>>>> '<div>1</div><div>2</div><div>3</div>'
com2[2].html() =>>>> '<div>1</div><div>2</div><div>3</div>'
Possible Solution
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working