Skip to content

Commit

Permalink
fix(migrator): be aware of the project's vue version (#6794)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanlivens committed Oct 29, 2021
1 parent c71ab1e commit 0d0a485
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/@vue/cli-plugin-unit-jest/migrator/index.js
@@ -1,5 +1,7 @@
/** @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'
Expand All @@ -12,8 +14,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']) {
Expand Down

0 comments on commit 0d0a485

Please sign in to comment.