Skip to content

Commit e4d67d6

Browse files
aitboudadyyx990803
authored andcommitted
feat(e2e-nightwatch): allow using custom config via --config flag (#1016)
1 parent 49677ba commit e4d67d6

File tree

1 file changed

+12
-9
lines changed
  • packages/@vue/cli-plugin-e2e-nightwatch

1 file changed

+12
-9
lines changed

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

+12-9
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,20 @@ module.exports = (api, options) => {
3131
return serverPromise.then(({ server, url }) => {
3232
// expose dev server url to tests
3333
process.env.VUE_DEV_SERVER_URL = url
34-
// expose user options to config file
35-
const fs = require('fs')
36-
let userOptionsPath, userOptions
37-
if (fs.existsSync(userOptionsPath = api.resolve('nightwatch.config.js'))) {
38-
userOptions = require(userOptionsPath)
39-
} else if (fs.existsSync(userOptionsPath = api.resolve('nightwatch.json'))) {
40-
userOptions = require(userOptionsPath)
34+
if (rawArgs.indexOf('--config') === -1) {
35+
// expose user options to config file
36+
const fs = require('fs')
37+
let userOptionsPath, userOptions
38+
if (fs.existsSync(userOptionsPath = api.resolve('nightwatch.config.js'))) {
39+
userOptions = require(userOptionsPath)
40+
} else if (fs.existsSync(userOptionsPath = api.resolve('nightwatch.json'))) {
41+
userOptions = require(userOptionsPath)
42+
}
43+
process.env.VUE_NIGHTWATCH_USER_OPTIONS = JSON.stringify(userOptions || {})
44+
45+
rawArgs.push('--config', require.resolve('./nightwatch.config.js'))
4146
}
42-
process.env.VUE_NIGHTWATCH_USER_OPTIONS = JSON.stringify(userOptions || {})
4347

44-
rawArgs.push('--config', require.resolve('./nightwatch.config.js'))
4548
if (rawArgs.indexOf('--env') === -1) {
4649
rawArgs.push('--env', 'chrome')
4750
}

0 commit comments

Comments
 (0)