vuejs / vue-jest

Jest Vue transformer
MIT License
746 stars 157 forks source link

[vue3-jest] - createVNode/createElementVNode is not a function #396

Closed seba4 closed 2 years ago

seba4 commented 2 years ago

In my project i have just upgraded to Vue 3 and app is running normally but when i try to run tests i get error:

Component Test.vue) Example1:

<template>
    <div>
    </div>
</template>

Component Test.vue Example2:

<template>
    <div>
        <div>test</div>
    </div>
</template>

I am shallowMounting/mount OverviewOption.vue which has imported Test.vue.

  1. If Test.vue is imported from same folder as OverviewOption.vue both examples are working and tests PASS
  2. If Test.vue is imported from SubModule Example1 does not throw error Example2 throws an error ERROR1: (3.1.0 Vue): createVNode is not a function ERROR2 (3.2.19 Vue): _vue.createElementVNode) is not a function

Only difference in OverviewOption.vue: import Test from 'design-system/components/Test/Test.vue' import Test from './Test.vue'

Any idea where the problem is or what should i check?

LinusBorg commented 2 years ago

Sounds to me like the "submodule" also has a node_modules folder, in which a wrong Version of Vue is installed (Vue 2 still?), or something like that.

seba4 commented 2 years ago

I did a bit more testing. And yea i have checked about this node_modules but no this is not there. Otherwise app is working if i open it in browser but not in Jest tests.

One finding that i noticed:

Project structure: /root

seba4 commented 2 years ago

I found out that the problem was in node_modules like you said, but it was not in same location but 2 levels up. This folder included different Vue version and because of that i had problems.