Skip to content

Commit da0c7e5

Browse files
committed
feat(test:e2e): specify command to run for tests
1 parent efbc20c commit da0c7e5

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

packages/@vue/cli-plugin-e2e-cypress/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ module.exports = (api, options) => {
88
'--headless': 'run in headless mode without GUI',
99
'--mode': 'specify the mode the dev server should run in. (default: production)',
1010
'--url': 'run e2e tests against given url instead of auto-starting dev server',
11-
'-s, --spec': '(headless only) runs a specific spec file. defaults to "all"'
11+
'-s, --spec': '(headless only) runs a specific spec file. defaults to "all"',
12+
'--command': 'vue-cli-service command to run (default: serve)'
1213
},
1314
details:
1415
`All Cypress CLI options are also supported:\n` +
@@ -17,12 +18,15 @@ module.exports = (api, options) => {
1718
removeArg(rawArgs, 'mode')
1819
removeArg(rawArgs, 'url')
1920
removeArg(rawArgs, 'config')
21+
removeArg(rawArgs, 'command')
2022

2123
info(`Starting e2e tests...`)
2224

25+
const command = args.command || 'serve'
26+
2327
const { url, server } = args.url
2428
? { url: args.url }
25-
: await api.service.run('serve')
29+
: await api.service.run(command)
2630

2731
const configs = typeof args.config === 'string' ? args.config.split(',') : []
2832
const cyArgs = [

packages/@vue/cli-plugin-e2e-nightwatch/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ module.exports = (api, options) => {
1313
'--use-selenium': 'use Selenium standalone server instead of chromedriver or geckodriver',
1414
'-e, --env': 'specify comma-delimited browser envs to run in (default: chrome)',
1515
'-t, --test': 'specify a test to run by name',
16-
'-f, --filter': 'glob to filter tests by filename'
16+
'-f, --filter': 'glob to filter tests by filename',
17+
'--command': 'vue-cli-service command to run (default: serve)'
1718
},
1819
details:
1920
`All Nightwatch CLI options are also supported.\n` +
@@ -42,7 +43,7 @@ module.exports = (api, options) => {
4243
}
4344

4445
// remove args
45-
;['url', 'mode'].forEach(toRemove => removeArg(rawArgs, toRemove))
46+
;['url', 'mode', 'command'].forEach(toRemove => removeArg(rawArgs, toRemove))
4647
// remove flags
4748
;['headless', 'use-selenium', 'parallel'].forEach(toRemove => removeArg(rawArgs, toRemove, 0))
4849

@@ -100,13 +101,13 @@ module.exports.defaultModes = {
100101
}
101102

102103
function startDevServer (args, api) {
103-
const { url } = args
104+
const { url, command } = args
104105

105106
if (url) {
106107
return Promise.resolve({ url })
107108
}
108109

109-
return api.service.run('serve')
110+
return api.service.run(command || 'serve')
110111
}
111112

112113
async function loadNightwatchConfig (rawArgs, api) {

0 commit comments

Comments
 (0)