vue-test-utils: RangeError: Maximum call stack size exceeded at Function.keys ()

Version

1.0.0-beta.24

Reproduction link

https://codesandbox.io/s/oq4n94v9lz

Steps to reproduce

Run the HelloWorld.spec.js

What is expected?

It’s expected that the component is mounted.

What is actually happening?

The following error is happening:

RangeError: Maximum call stack size exceeded
        at Function.keys (<anonymous>)

      at mergeData (node_modules/vue/dist/vue.runtime.common.js:1105:21)
      at mergeData (node_modules/vue/dist/vue.runtime.common.js:1113:7)
      at mergeData (node_modules/vue/dist/vue.runtime.common.js:1113:7)
      at mergeData (node_modules/vue/dist/vue.runtime.common.js:1113:7)
      at mergeData (node_modules/vue/dist/vue.runtime.common.js:1113:7)
      at mergeData (node_modules/vue/dist/vue.runtime.common.js:1113:7)
      at mergeData (node_modules/vue/dist/vue.runtime.common.js:1113:7)

I was able to track down the change that caused the problem by downgrading until version 1.0.0-beta.22, this specific version includes this chunk of code:

if (vueVersion > 2.2) {
    for (var c in _Vue.options.components) {
      if (!isRequiredComponent(c)) {
        _Vue.component(c, _Vue.extend(_Vue.options.components[c]));
      }
    }
  }

And for some reason it stucks at mergeData trying to resolve ElFormItem’s provide directive.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 3
  • Comments: 20 (5 by maintainers)

Most upvoted comments

I encountered the same problem. Has anyone been able to find a solution?

I experienced this error in the very specific situation of using vue-class-component and referencing this when giving value to a data in the class property style:

// without 'vue-class-component'
// works
export default {
  data () {
    return { myParent: this.$parent } // or anything, referencing `this` is the point
  }
}

// with 'vue-class-component'
import Vue from 'vue'
import Component from 'vue-class-component'

// still works
@Component({
  data () {
    return { myParent: this.$parent }
  }
})
export default class MyComponent extends Vue {}

// breaks with 'RangeError: Maximum call stack size exceeded' at `mergeData`
@Component({ /* ... */ })
export default class MyComponent extends Vue {
  myParent = this.$parent
}

Any of the above code works fine in development, but the third breaks in test.

Done.

I created this branch for you: https://github.com/Edza/Intertyper/tree/vue-test-utils-bug-repro

Simply clone the repo and run: npm i && npm run test:unit

Thanks for the fast reply 😜😜

Will get: at mergeData (dist\webpack:\node_modules\vue\dist\vue.runtime.esm.js:1135:1) at mergeData (dist\webpack:\node_modules\vue\dist\vue.runtime.esm.js:1135:1) at mergeData (dist\webpack:\node_modules\vue\dist\vue.runtime.esm.js:1135:1) at mergeData (dist\webpack:\node_modules\vue\dist\vue.runtime.esm.js:1135:1) at mergeData (dist\webpack:\node_modules\vue\dist\vue.runtime.esm.js:1135:1) at mergeData (dist\webpack:\node_modules\vue\dist\vue.runtime.esm.js:1135:1) at VueComponent.mergedDataFn (dist\webpack:\node_modules\vue\dist\vue.runtime.esm.js:1163:1) at getData (dist\webpack:\node_modules\vue\dist\vue.runtime.esm.js:3413:1) at initData (dist\webpack:\node_modules\vue\dist\vue.runtime.esm.js:3370:1) at initState (dist\webpack:\node_modules\vue\dist\vue.runtime.esm.js:3307:1) at VueComponent.Vue._init (dist\webpack:\node_modules\vue\dist\vue.runtime.esm.js:4624:1) at new VueComponent (dist\webpack:\node_modules\vue\dist\vue.runtime.esm.js:4794:1) at createComponentInstanceForVnode (dist\webpack:\node_modules\vue\dist\vue.runtime.esm.js:4306:1) at init (dist\webpack:\node_modules\vue\dist\vue.runtime.esm.js:4127:1) at createComponent (dist\webpack:\node_modules\vue\dist\vue.runtime.esm.js:5604:1) at createElm (dist\webpack:\node_modules\vue\dist\vue.runtime.esm.js:5551:1) at VueComponent.patch [as patch] (dist\webpack:\node_modules\vue\dist\vue.runtime.esm.js:6087:1) at VueComponent.Vue._update (dist\webpack:\node_modules\vue\dist\vue.runtime.esm.js:2656:1) at VueComponent.updateComponent (dist\webpack:\node_modules\vue\dist\vue.runtime.esm.js:2784:1) at Watcher.get (dist\webpack:\node_modules\vue\dist\vue.runtime.esm.js:3138:1) at new Watcher (dist\webpack:\node_modules\vue\dist\vue.runtime.esm.js:3127:1) at mountComponent (dist\webpack:\node_modules\vue\dist\vue.runtime.esm.js:2791:1) at VueComponent…/node_modules/vue/dist/vue.runtime.esm.js.Vue.$mount (dist\webpack:\node_modules\vue\dist\vue.runtime.esm.js:7995:1) at mount (dist\webpack:\node_modules@vue\test-utils\dist\vue-test-utils.js:5645:1) at shallowMount (dist\webpack:\node_modules@vue\test-utils\dist\vue-test-utils.js:5690:1) at Context.<anonymous> (dist\webpack:\tests\unit\Questions.spec.ts:11:21)

Can you post a reproduction in a GitHub repo please @Edza ? I want to get this fixed but had trouble reproducing the codesandbox in the vue-test-utils repo

As @nelsonsar, until we add a fix, you can workaround this by stubbing the problem component:

const wrapper = mount({
  stubs: {
    ProblemComponent: true
  }
})

I was able to work around the issue by stubbing the component with its own implementation, maybe this helps until a fix arrives.