Skip to content

Bug: [Vue warn] Non-function value encountered for default slot on stubbed teleport#1829

@freakzlike

Description

@freakzlike

Describe the bug
After update from 2.1.0 to 2.2.0, tests with stubs:{teleport: true } produce a warning:

[Vue warn]: Non-function value encountered for default slot. Prefer function slots for better performance. at <Teleport to="body" > at <Anonymous ref="VTU_COMPONENT" > at <VTUROOT> 

To Reproduce
Able to reproduce within VTU unit test

it('opts in to stubbing teleport ',()=>{
constComp={
template: `<teleport to="body"><div id="content" /></teleport>`
}
constwrapper=mount(Comp,{
global: {
stubs: {
teleport: true
}
}
})
expect(wrapper.html()).toBe(
'<teleport-stub to="body">\n'+
' <div id="content"></div>\n'+
'</teleport-stub>'
)
})

Expected behavior
Not print a warning

Related information:

  • @vue/test-utils version: 2.2.0
  • Vue version: 3.2.41
  • node version: 16.18.0
  • npm (or yarn) version: [email protected]

Additional context
I think this might come from the stubs refactoring and some previous special handling on the teleport child nodes, where they have been explicit passed as function:

()=>children

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions