This repository was archived by the owner on Feb 28, 2024. It is now read-only.
forked from vuejs/vue-cli
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathe2e.js
59 lines (55 loc) · 1.53 KB
/
e2e.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const { installedBrowsers } = require('@vue/cli-shared-utils')
module.exports = cli => {
cli.injectFeature({
name: 'E2E Testing',
value: 'e2e',
short: 'E2E',
description: 'Add an End-to-End testing solution to the app like Cypress or Nightwatch',
link: 'https://github.com/vuejs/vue-cli/tree/dev/docs#e2e-testing',
plugins: ['e2e-cypress', 'e2e-nightwatch']
})
cli.injectPrompt({
name: 'e2e',
when: answers => answers.features.includes('e2e'),
type: 'list',
message: 'Pick a E2E testing solution:',
choices: [
{
name: 'Cypress (Test in Chrome, Firefox, MS Edge, and Electron)',
value: 'cypress',
short: 'Cypress'
},
{
name: 'Nightwatch (WebDriver-based)',
value: 'nightwatch',
short: 'Nightwatch'
}
]
})
cli.injectPrompt({
name: 'webdrivers',
when: answers => answers.e2e === 'nightwatch',
type: `checkbox`,
message: `Pick browsers to run end-to-end test on`,
choices: [
{
name: `Chrome`,
value: 'chrome',
checked: true
},
{
name: 'Firefox',
value: 'firefox',
// check the "Firefox" option if user has installed it
checked: !!installedBrowsers.firefox
}
]
})
cli.onPromptComplete((answers, options) => {
if (answers.e2e === 'cypress') {
options.plugins['@vue/cli-plugin-e2e-cypress'] = {}
} else if (answers.e2e === 'nightwatch') {
options.plugins['@vue/cli-plugin-e2e-nightwatch'] = {}
}
})
}