Skip to content

Bug: incapable of getting value from a teleport to body #1781

@VividLemon

Description

@VividLemon

Describe the bug

The documentation is not clear about getting values from a value that is not a component.

To Reproduce

teleport to body, try to get a component wrapper from the body.
With stubbed out teleport, reactivity changes via setProps doesn't work

Expected behavior

Stubbed teleport manages to get the value, but it doesn't matter, as reactivity on those components doesn't work.

Ie. attempting to use await wrapper.setProps({}) doesn't change anything.

Related information:

  • @vue/test-utils version: 2.x.x "^2.0.2",
  • Vue "vue": "^3.2.37",
  • node version: 16
  • npm (or yarn) version:"[email protected]"

Additional context

Without global: {stubs: {teleport: true}}, it's impossible to use the test utils on the wrapper. With global: {stubs: {teleport: true}}, reactivity is broken and disregards setProps

Regardless, it would be better if I could simply use find() to get a value from the "body" ~~ where it is teleported to

  it('div has class fade when not prop noFade', async () => {
    const wrapper = mount(BModal, {
      global: {stubs: {teleport: true}},
      props: {noFade: false},
    })
    const $div = wrapper.get('div')
    expect($div.classes()).toContain('fade')
    await wrapper.setProps({noFade: true})
    expect($div.classes()).not.toContain('fade')
  })
const modalClasses = computed(() => [
  {
    fade: !noFadeBoolean.value,
    show: showBoolean.value,
  },
  props.modalClass,
])

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