jeudi 21 juin 2018

TypeError: Cannot read property '$el' of undefined when trying to mount a component containing a element-ui dropdown(

I am trying to test an Vue component which uses element-ui for styling using jest and vue-test-utils.

I am getting below error on mounting the component and my test fails. To my surprise when i try to print the property on console when i am running my application on development server it is displaying the value without any error.

If i comment tag. tests run without any error.

TypeError: Cannot read property '$el' of undefined
  at VueComponent.mounted (node_modules/element-ui/lib/element-ui.common.js:9115:54)
  at callHook (node_modules/vue/dist/vue.runtime.common.js:2919:21)
  at Object.insert (node_modules/vue/dist/vue.runtime.common.js:4156:7)
  at invokeInsertHook (node_modules/vue/dist/vue.runtime.common.js:5958:28)
  at VueComponent.patch [as __patch__] (node_modules/vue/dist/vue.runtime.common.js:6177:5)
  at VueComponent.Vue._update (node_modules/vue/dist/vue.runtime.common.js:2658:19)
  at VueComponent.updateComponent (node_modules/vue/dist/vue.runtime.common.js:2786:10)
  at Watcher.get (node_modules/vue/dist/vue.runtime.common.js:3140:25)
  at new Watcher (node_modules/vue/dist/vue.runtime.common.js:3129:12)
  at mountComponent (node_modules/vue/dist/vue.runtime.common.js:2793:3)
  at VueComponent.Object.<anonymous>.Vue.$mount (node_modules/vue/dist/vue.runtime.common.js:7997:10)
  at mount (node_modules/@vue/test-utils/dist/vue-test-utils.js:5559:21)

Anybody with a solution for this?

Aucun commentaire:

Enregistrer un commentaire