You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have recently migrated from Vue2 to Vue3 and in the process we were having problems with testing. Our setup is to use Jest and then also babel-plugin-rewire to be able to mock functions from the same module as the unit under test. The setup in Vue2 worked just fine but after upgrading to Vue3 (and really vue3-jest) the setup began to fail claiming RewireAPI had already been declared.
/Users/colin.maxfield/workspace/test-sites/vue-jest-examples/sanity/src/components/TheWelcome.vue:430
var _RewireAPI__ = exports.__RewireAPI__ = {};
^
SyntaxError: Identifier '_RewireAPI__' has already been declared
After digging in to the process function of vue3-jest it seemed like all of the Vue special imports were being rewired but separately from the script of the component resulting in a lot of attempts to declare things by the same name (like the error above). I setup a simple sanity test for both Vue3 and Vue2 and found that the same setup passes in Vue2 but fails in Vue3 (https://github.com/colingm/vue-jest-examples).
In my test repo there is a .babelrc that is setup with babel-env like below and I found that if I removed the environment configuration there that the Vue3 version also started to work (sadly we need those in our project). Any ideas on where I could dig in code to try to find what the difference is or something that might help here?
We have recently migrated from Vue2 to Vue3 and in the process we were having problems with testing. Our setup is to use Jest and then also babel-plugin-rewire to be able to mock functions from the same module as the unit under test. The setup in Vue2 worked just fine but after upgrading to Vue3 (and really vue3-jest) the setup began to fail claiming
RewireAPI
had already been declared.After digging in to the process function of vue3-jest it seemed like all of the Vue special imports were being rewired but separately from the script of the component resulting in a lot of attempts to declare things by the same name (like the error above). I setup a simple sanity test for both Vue3 and Vue2 and found that the same setup passes in Vue2 but fails in Vue3 (https://github.com/colingm/vue-jest-examples).
In my test repo there is a
.babelrc
that is setup with babel-env like below and I found that if I removed the environment configuration there that the Vue3 version also started to work (sadly we need those in our project). Any ideas on where I could dig in code to try to find what the difference is or something that might help here?The text was updated successfully, but these errors were encountered: