Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
freakzlike opened this issue Oct 25, 2022 · 3 comments · Fixed by #1833
Closed
Labels
bug Something isn't working

Comments

@freakzlike
Copy link
Collaborator

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 ', () => {
const Comp = {
template: `<teleport to="body"><div id="content" /></teleport>`
}
const wrapper = 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: pnpm@7.14.0

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

@freakzlike freakzlike added the bug Something isn't working label Oct 25, 2022
@gabriellatavares
Copy link

i'm having the same issue

@FlorentGimaret
Copy link

I'm facing the same issue

cexbrayat added a commit to cexbrayat/vue-test-utils-next that referenced this issue Oct 26, 2022
cexbrayat added a commit to cexbrayat/vue-test-utils-next that referenced this issue Oct 26, 2022
@cexbrayat
Copy link
Member

I have a hacky workaround that gets rid of the warning in #1833 but I'm not convinced this is the proper way.

cexbrayat added a commit to cexbrayat/vue-test-utils-next that referenced this issue Oct 27, 2022
cexbrayat added a commit to cexbrayat/vue-test-utils-next that referenced this issue Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants