From 9ebb99c6bc3f02eee154737d945e8b0bb4a9a2fb Mon Sep 17 00:00:00 2001 From: stefanlivens Date: Thu, 28 Oct 2021 16:13:38 +0200 Subject: [PATCH 1/2] Update index.js Make migrator smarter, or at least vue2-vue3 aware before adding the right @vue/vue-jest package --- .../@vue/cli-plugin-unit-jest/migrator/index.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/@vue/cli-plugin-unit-jest/migrator/index.js b/packages/@vue/cli-plugin-unit-jest/migrator/index.js index e713746fe0..36421f85a6 100644 --- a/packages/@vue/cli-plugin-unit-jest/migrator/index.js +++ b/packages/@vue/cli-plugin-unit-jest/migrator/index.js @@ -1,5 +1,8 @@ /** @param {import('@vue/cli/lib/MigratorAPI')} api MigratorAPI */ -module.exports = (api) => { +module.exports = (api, options, rootOptions) => { + + const isVue3 = rootOptions && rootOptions.vueVersion === '3' + api.extendPackage(pkg => { const newDevDeps = { 'jest': '^27.1.0' @@ -12,8 +15,12 @@ module.exports = (api) => { } if (!allDeps['vue-jest']) { - // Likely a Vue 2 project, and uses the builtin preset. - newDevDeps['@vue/vue3-jest'] = '^27.0.0-alpha.1' + // Likely from @vue/cli@4 + if (isVue3) { + newDevDeps['@vue/vue3-jest'] = '^27.0.0-alpha.3' + } else { + newDevDeps['@vue/vue2-jest'] = '^27.0.0-alpha.3' + } } if (allDeps['@vue/cli-plugin-typescript'] && !allDeps['ts-jest']) { From 80170ddef3e66ccd44773d55198ae1b79c38f6b3 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Fri, 29 Oct 2021 14:19:26 +0800 Subject: [PATCH 2/2] style: remove extraneous blank line to fix ESLint errors --- packages/@vue/cli-plugin-unit-jest/migrator/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/@vue/cli-plugin-unit-jest/migrator/index.js b/packages/@vue/cli-plugin-unit-jest/migrator/index.js index 36421f85a6..eb8410e54d 100644 --- a/packages/@vue/cli-plugin-unit-jest/migrator/index.js +++ b/packages/@vue/cli-plugin-unit-jest/migrator/index.js @@ -1,6 +1,5 @@ /** @param {import('@vue/cli/lib/MigratorAPI')} api MigratorAPI */ module.exports = (api, options, rootOptions) => { - const isVue3 = rootOptions && rootOptions.vueVersion === '3' api.extendPackage(pkg => {