Open stefanlivens opened 2 years ago
Hi @stefanlivens and thank you for opening this issue. I'm the one who introduced this regression in #6627 , my bad. I just changed the existing code without thinking too much about it (I was focused on Vue 3 support).
Please open a PR and I'll gladly review it 👍. Maybe we should even have a test for this migration (I assumed there was one, but obviously there is none otherwise we would have caught this).
Here you go: very very basic: https://github.com/vuejs/vue-cli/pull/6794
Version
5.0.0-beta.6
Environment info
Steps to reproduce
vue upgrade --next in a vue2 application with vue-cli@4
this will install the latest versions of the cli-plugins, and will run the migrator script of them. for Vue2 applications, this will result in installing @vue/vue3-jest instead of the vue2 variant. So running the unit-tests will fail. (because jest expects this for the .vue files)
What is expected?
When I have a vue2 application, and 'upgrade' to the latest versions, the correct packages are installed.
What is actually happening?
Even with a vue2 application, I get the @vue/vue3-jest :'^27.0.0-alpha.1' package, so I have to manually install the right one (@vue/vue2-jest@27.0.0-alpha.2)
My feeling is the migrator/index.js is not 'complete' enough. Right now it only contains a check like this:
if (!allDeps['vue-jest']) { // Likely a Vue 2 project, and uses the builtin preset. newDevDeps['@vue/vue3-jest'] = '^27.0.0.alpha.1' }
I think this needs to be corrected or expanded to make the distinction between vue2 and vue3. Maybe like this (pseudocode):
if (!allDeps['vue-jest']) { // Likely a vue-cli@4 application, and uses the builtin preset. if (vue2) { newDevDeps['@vue/vue2-jest'] = '^27.0.0-alpha.2' } if (vue3) { newDevDeps['@vue/vue3-jest'] = '^27.0.0-alpha.1' } }
I'm happy to create a PR for it, but I want first to hear your opinion, because i'm not 100% clear about the "!allDeps['vue-jest'] => Likely a Vue 2 project, and uses the builtin preset."
Thanks in advance.