Skip to content

Commit 0d0a485

Browse files
authored
fix(migrator): be aware of the project's vue version (#6794)
1 parent c71ab1e commit 0d0a485

File tree

1 file changed

+9
-3
lines changed
  • packages/@vue/cli-plugin-unit-jest/migrator

1 file changed

+9
-3
lines changed

packages/@vue/cli-plugin-unit-jest/migrator/index.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/** @param {import('@vue/cli/lib/MigratorAPI')} api MigratorAPI */
2-
module.exports = (api) => {
2+
module.exports = (api, options, rootOptions) => {
3+
const isVue3 = rootOptions && rootOptions.vueVersion === '3'
4+
35
api.extendPackage(pkg => {
46
const newDevDeps = {
57
'jest': '^27.1.0'
@@ -12,8 +14,12 @@ module.exports = (api) => {
1214
}
1315

1416
if (!allDeps['vue-jest']) {
15-
// Likely a Vue 2 project, and uses the builtin preset.
16-
newDevDeps['@vue/vue3-jest'] = '^27.0.0-alpha.1'
17+
// Likely from @vue/cli@4
18+
if (isVue3) {
19+
newDevDeps['@vue/vue3-jest'] = '^27.0.0-alpha.3'
20+
} else {
21+
newDevDeps['@vue/vue2-jest'] = '^27.0.0-alpha.3'
22+
}
1723
}
1824

1925
if (allDeps['@vue/cli-plugin-typescript'] && !allDeps['ts-jest']) {

0 commit comments

Comments
 (0)