Skip to content

Commit 05391b6

Browse files
committed
fix: e2e runner args passing
close #1393
1 parent 60f0a0a commit 05391b6

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

packages/@vue/cli-plugin-e2e-cypress/README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ Cypress offers a rich interactive interface for running E2E tests, but currently
2525
-s, --spec (headless only) runs a specific spec file. defaults to "all"
2626
```
2727

28-
Additionally, [all Cypress CLI options for `cypress run` are also supported](https://docs.cypress.io/guides/guides/command-line.html#cypress-run).
28+
Additionally:
29+
30+
- In GUI mode, [all Cypress CLI options for `cypress open` are also supported](https://docs.cypress.io/guides/guides/command-line.html#cypress-open);
31+
- In `--headless` mode, [all Cypress CLI options for `cypress run` are also supported](https://docs.cypress.io/guides/guides/command-line.html#cypress-run).
2932

3033
## Configuration
3134

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = (api, options) => {
1414
`All Cypress CLI options are also supported:\n` +
1515
chalk.yellow(`https://docs.cypress.io/guides/guides/command-line.html#cypress-run`)
1616
}, async (args, rawArgs) => {
17-
removeArg(rawArgs, 'headless')
17+
removeArg(rawArgs, 'headless', 0)
1818
removeArg(rawArgs, 'mode')
1919
removeArg(rawArgs, 'url')
2020

@@ -58,11 +58,11 @@ module.exports.defaultModes = {
5858
'test:e2e': 'production'
5959
}
6060

61-
function removeArg (rawArgs, arg) {
61+
function removeArg (rawArgs, arg, offset = 1) {
6262
const matchRE = new RegExp(`^--${arg}`)
6363
const equalRE = new RegExp(`^--${arg}=`)
6464
const i = rawArgs.findIndex(arg => matchRE.test(arg))
6565
if (i > -1) {
66-
rawArgs.splice(i, equalRE.test(rawArgs[i]) ? 1 : 2)
66+
rawArgs.splice(i, offset + (equalRE.test(rawArgs[i]) ? 0 : 1))
6767
}
6868
}

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

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
function removeArg (rawArgs, arg) {
2-
const matchRE = new RegExp(`^--${arg}`)
3-
const equalRE = new RegExp(`^--${arg}=`)
4-
const i = rawArgs.findIndex(arg => matchRE.test(arg))
5-
if (i > -1) {
6-
rawArgs.splice(i, equalRE.test(rawArgs[i]) ? 1 : 2)
7-
}
8-
}
9-
101
module.exports = (api, options) => {
112
api.registerCommand('test:e2e', {
123
description: 'run e2e tests with nightwatch',
@@ -79,3 +70,12 @@ module.exports = (api, options) => {
7970
module.exports.defaultModes = {
8071
'test:e2e': 'production'
8172
}
73+
74+
function removeArg (rawArgs, arg, offset = 1) {
75+
const matchRE = new RegExp(`^--${arg}`)
76+
const equalRE = new RegExp(`^--${arg}=`)
77+
const i = rawArgs.findIndex(arg => matchRE.test(arg))
78+
if (i > -1) {
79+
rawArgs.splice(i, offset + (equalRE.test(rawArgs[i]) ? 0 : 1))
80+
}
81+
}

0 commit comments

Comments
 (0)