forked from vuejs/vue-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunit.js
37 lines (35 loc) · 917 Bytes
/
unit.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
module.exports = cli => {
cli.injectFeature({
name: 'Unit Testing',
value: 'unit',
short: 'Unit',
description: 'Add a Unit Testing solution like Jest or Mocha',
link: 'https://cli.vuejs.org/config/#unit-testing',
plugins: ['unit-jest', 'unit-mocha']
})
cli.injectPrompt({
name: 'unit',
when: answers => answers.features.includes('unit'),
type: 'list',
message: 'Pick a unit testing solution:',
choices: [
{
name: 'Jest',
value: 'jest',
short: 'Jest'
},
{
name: 'Mocha + Chai (requires webpack 4)',
value: 'mocha',
short: 'Mocha'
}
]
})
cli.onPromptComplete((answers, options) => {
if (answers.unit === 'mocha') {
options.plugins['@vue/cli-plugin-unit-mocha'] = {}
} else if (answers.unit === 'jest') {
options.plugins['@vue/cli-plugin-unit-jest'] = {}
}
})
}