vuejs / vue-test-utils

Component Test Utils for Vue 2
https://vue-test-utils.vuejs.org
MIT License
3.57k stars 669 forks source link

ComponentOptions.tag are undefined of slot component. #1000

Open mylmz10 opened 6 years ago

mylmz10 commented 6 years ago

Version

1.0.0-beta.25

Reproduction link

https://codesandbox.io/s/vnz4nm5py?module=%2Ftests%2Funit%2Fcomponents%2FParent.spec.js

Steps to reproduce

  1. Create Parent Component
  2. Create Child Component
  3. Child component is slot of parent compoent and render.
  4. Get the child component tag of slots
  5. wrapper.vm.$slots.default.componentOptions.tag is undefined.

What is expected?

It's given 'undefined'

What is actually happening?

Will return ComponentOptions.tag


Is there any solution of how i get componentOptions.tag?

eddyerburgh commented 6 years ago

A vnode's componentOptions does not have a tag value if you pass a constructor as the first argument of createElement (https://github.com/vuejs/vue/blob/dev/src/core/vdom/create-element.js#L119).

Your reproduction demonstrates the expected behavior.

mylmz10 commented 5 years ago

@eddyerburgh hi, i can get the componentOptions.tag of each slots on created() or mounted(). On the test, componentOptions.tag is undefined. Why they are different? Therefore i can't test the component and coverage happened very bad.

Is it a bug or do i mistake?

Example component: https://github.com/Nativescript-Vue-Web/Nativescript-Vue-Web/blob/master/src/components/ActionBar.vue

WingGao commented 5 years ago

I think it should need to be fixed, some people will use the componentOptions.tag to check the component type.

zhixinpeng commented 5 years ago

I have the same problem, I need componentOptions.tag to check the component type, but it is undefined

mylmz10 commented 5 years ago

It seems resolved on reproduction link on the first post. @zhixinpeng could you write version of test util?

zhixinpeng commented 5 years ago

1.0.0-beta.29

mylmz10 commented 5 years ago

@zhixinpeng sorry it still seems unsolved, you right. The componentOptions.tag is undefined

shannonarcher commented 4 years ago

any news on this issue?