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

Cannot read property 'subTree' of undefined if expose() is used #435

Closed
KaelWD opened this issue Mar 2, 2021 · 4 comments
Closed

Cannot read property 'subTree' of undefined if expose() is used #435

KaelWD opened this issue Mar 2, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@KaelWD
Copy link

KaelWD commented Mar 2, 2021

it('works with expose', async () => {
  const Component = defineComponent({
    setup (props, { expose }) {
      const val = ref('')

      expose({
        val
      })

      return () => h('div')
    }
  })

  const wrapper = mount(Component)
})

In VueWrapper.hasMultipleRoots, this.vm is the exposed object instead of the component instance.

https://github.com/vuejs/vue-test-utils-next/blob/c667907bac0db961439ccdca0644b54a5f5ee382/src/mount.ts#L437-L449

Should be something like this but always returning i.proxy:

https://github.com/vuejs/vue-next/blob/fbf2d68bbcde75c95363e1fd17946c720d0f3925/packages/runtime-core/src/componentPublicInstance.ts#L207-L218

KaelWD added a commit to vuetifyjs/vuetify that referenced this issue Mar 2, 2021
@lmiller1990 lmiller1990 added the bug Something isn't working label Mar 3, 2021
@lmiller1990
Copy link
Member

Thanks for the bug report and detective work. If you don't get a change to dig into this more, I will try get a fix done sooner rather than later. Have not played with expose much (yet).

@KaelWD
Copy link
Author

KaelWD commented Mar 4, 2021

I think this is actually vue's fault, if expose is used it doesn't expose the component's proxy at all:
vuejs/core@0e59770#diff-56930a63772d2e89f19432918b9d6ed851ede4159b0d32404e0c1d8c159fec99R313-R315

@freakzlike
Copy link
Collaborator

@KaelWD Can you verify this again with rc.21? There have been some fixes and changes (#1067 and e80b7b2) and also a unit test with this case already exists.

@lmiller1990
Copy link
Member

Looks like we do have a unit test - let's close this. We can re-open if it's not actually fixed.

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

No branches or pull requests

3 participants