Closed
Description
Is there a way to somehow pass component instances to the slots property of mount? The use case is, say I have a component that has a required property:
export default {
name: 'Message',
props: {
message: {
type: String,
required: true,
validator: value => value.length > 1
}
}
Then if in a test I wanna add a list of Message as the default slots, I cannot do it like it's documented: I'll get a "message" property is required
error:
mount(MessageList, {
slots: {
default: messages
}
})
I tried using mount and getting the vm out of it, or also extending the component and using new Vue(...)
but I get the error [Vue warn]: Failed to mount component: template or render function not defined.
:
beforeEach(() => {
const indexes = [0, 1, 2]
const messages = indexes.map(i => mount(Message, {
propsData: { message: `Message ${i}` }
}).vm)
cmp = mount(MessageList, {
slots: {
default: messages
}
})
})
So, how's it possible to accomplish that?