Skip to content

Vue test utils require extra parameters in Karma tests

The following discussion from gitlab-ee!8593 should be addressed:

  • @pslaughter started a discussion: (+3 comments)

    vent: This was causing me to lose my mind... Before adding localVue and sync: false, I was experiencing some very weird behavior with these vue-test-utils tests.

    The Problems

    The tests worked when ran individually, but running yarn run karma revealed the following:

    • Unrelated tests were failing their assertions.
    • This test triggered a Max call stack size exceeded. It looked like there was a forever loop when trying to shallowMount 🤷.

    Why localVue?

    It looks like there's some issues when vue-test-utils touches a component and the component is used in a separate test that doesn't use vue-test-utils. For example, when I tried running mr_widget_pipeline_container_spec.js without setting localVue it would "stub" the child pipeline component, causing it to never be rendered properly in any other test 😱.

    Why sync: false?

    I honestly have no idea why this component was triggering a forever loop, but it's probably related to specs stepping onto eachother's toes somehow... I'm thinking that the Icon component might be the real culprit...

    (Pinging @iamphill & @psimyn since you might be interested in this)

Edited by Inactive Account