Skip to content

Commit 563b76d

Browse files
feat: Upgraded Nightwatch to 1.6.4, updated distribued config
1 parent f263a7d commit 563b76d

File tree

4 files changed

+291
-112
lines changed

4 files changed

+291
-112
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ module.exports = (api, options) => {
4242
}
4343

4444
// remove args
45-
;['url', 'mode'].forEach(toRemove => removeArg(rawArgs, toRemove))
45+
['url', 'mode'].forEach(toRemove => removeArg(rawArgs, toRemove));
4646
// remove flags
47-
;['headless', 'use-selenium', 'parallel'].forEach(toRemove => removeArg(rawArgs, toRemove, 0))
47+
['headless', 'use-selenium', 'parallel'].forEach(toRemove => removeArg(rawArgs, toRemove, 0))
4848

4949
return Promise.all([
5050
startDevServer(args, api),
@@ -127,7 +127,7 @@ async function loadNightwatchConfig (rawArgs, api) {
127127

128128
process.env.VUE_NIGHTWATCH_USER_OPTIONS = JSON.stringify(userOptions || {})
129129

130-
rawArgs.push('--config', require.resolve('./nightwatch.config.js'))
130+
rawArgs.push('--config', require.resolve('./nightwatch.conf.js'))
131131
}
132132
}
133133

Lines changed: 285 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,285 @@
1+
// Autogenerated by Nightwatch
2+
// Refer to the online docs for more details: https://nightwatchjs.org/gettingstarted/configuration/
3+
const path = require('path')
4+
const deepmerge = require('deepmerge')
5+
6+
const Services = {}
7+
loadServices()
8+
9+
const userOptions = JSON.parse(process.env.VUE_NIGHTWATCH_USER_OPTIONS || '{}')
10+
const concurrentMode = process.env.VUE_NIGHTWATCH_CONCURRENT === '1'
11+
const useSelenium = process.env.VUE_NIGHTWATCH_USE_SELENIUM === '1'
12+
const startHeadless = process.env.VUE_NIGHTWATCH_HEADLESS === '1'
13+
const chromeArgs = []
14+
const geckoArgs = []
15+
16+
if (startHeadless) {
17+
chromeArgs.push('headless')
18+
geckoArgs.push('--headless')
19+
}
20+
21+
const defaultSettings = {
22+
// An array of folders (excluding subfolders) where your tests are located;
23+
// if this is not specified, the test source must be passed as the second argument to the test runner.
24+
src_folders: ['tests/e2e/specs'],
25+
26+
// See https://nightwatchjs.org/guide/working-with-page-objects/
27+
page_objects_path: 'tests/e2e/page-objects',
28+
29+
// See https://nightwatchjs.org/guide/extending-nightwatch/#writing-custom-commands
30+
custom_commands_path: 'tests/e2e/custom-assertions',
31+
32+
// See https://nightwatchjs.org/guide/extending-nightwatch/#writing-custom-assertions
33+
custom_assertions_path: 'tests/e2e/custom-commands',
34+
35+
// See https://nightwatchjs.org/guide/#external-globals
36+
globals_path: path.resolve('tests/e2e/globals.js'),
37+
38+
output_folder: 'tests/e2e/reports',
39+
40+
webdriver: {},
41+
42+
test_settings: {
43+
default: {
44+
disable_error_log: false,
45+
launch_url: '${VUE_DEV_SERVER_URL}', // eslint-disable-line no-template-curly-in-string
46+
47+
screenshots: {
48+
enabled: false,
49+
path: 'screens',
50+
on_failure: true
51+
},
52+
53+
desiredCapabilities: {
54+
browserName: 'firefox'
55+
},
56+
57+
webdriver: {
58+
start_process: true,
59+
server_path: Services.geckodriver ? Services.geckodriver.path : ''
60+
},
61+
62+
test_workers: {
63+
enabled: concurrentMode,
64+
workers: 'auto'
65+
}
66+
},
67+
68+
safari: {
69+
desiredCapabilities: {
70+
browserName: 'safari',
71+
alwaysMatch: {
72+
acceptInsecureCerts: false
73+
}
74+
},
75+
webdriver: {
76+
port: 4445,
77+
start_process: true,
78+
server_path: '/usr/bin/safaridriver'
79+
}
80+
},
81+
82+
firefox: {
83+
desiredCapabilities: {
84+
browserName: 'firefox',
85+
alwaysMatch: {
86+
// Enable this if you encounter unexpected SSL certificate errors in Firefox
87+
// acceptInsecureCerts: true,
88+
'moz:firefoxOptions': {
89+
args: geckoArgs
90+
}
91+
}
92+
},
93+
webdriver: {
94+
start_process: true,
95+
port: 4444,
96+
server_path: Services.geckodriver ? Services.geckodriver.path : '',
97+
cli_args: [
98+
// very verbose geckodriver logs
99+
// '-vv'
100+
]
101+
}
102+
},
103+
104+
chrome: {
105+
desiredCapabilities: {
106+
browserName: 'chrome',
107+
chromeOptions: {
108+
// This tells Chromedriver to run using the legacy JSONWire protocol (not required in Chrome 78)
109+
// w3c: false,
110+
// More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
111+
args: chromeArgs
112+
}
113+
},
114+
115+
webdriver: {
116+
start_process: true,
117+
port: 9515,
118+
server_path: Services.chromedriver ? Services.chromedriver.path : '',
119+
cli_args: [
120+
// --verbose
121+
]
122+
}
123+
},
124+
125+
/// ///////////////////////////////////////////////////////////////////////////////
126+
// Configuration for when using the browserstack.com cloud service |
127+
// |
128+
// Please set the username and access key by setting the environment variables: |
129+
// - BROWSERSTACK_USER |
130+
// - BROWSERSTACK_KEY |
131+
// .env files are supported |
132+
/// ///////////////////////////////////////////////////////////////////////////////
133+
browserstack: {
134+
selenium: {
135+
host: 'hub-cloud.browserstack.com',
136+
port: 443
137+
},
138+
// More info on configuring capabilities can be found on:
139+
// https://www.browserstack.com/automate/capabilities?tag=selenium-4
140+
desiredCapabilities: {
141+
'bstack:options': {
142+
local: 'false',
143+
userName: '${BROWSERSTACK_USER}', // eslint-disable-line no-template-curly-in-string
144+
accessKey: '${BROWSERSTACK_KEY}' // eslint-disable-line no-template-curly-in-string
145+
}
146+
},
147+
148+
disable_error_log: true,
149+
webdriver: {
150+
keep_alive: true,
151+
start_process: false
152+
}
153+
},
154+
155+
'browserstack.chrome': {
156+
extends: 'browserstack',
157+
desiredCapabilities: {
158+
browserName: 'chrome',
159+
chromeOptions: {
160+
// This tells Chromedriver to run using the legacy JSONWire protocol
161+
// More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
162+
w3c: false
163+
}
164+
}
165+
},
166+
167+
'browserstack.firefox': {
168+
extends: 'browserstack',
169+
desiredCapabilities: {
170+
browserName: 'firefox'
171+
}
172+
},
173+
174+
'browserstack.ie': {
175+
extends: 'browserstack',
176+
desiredCapabilities: {
177+
browserName: 'IE',
178+
browserVersion: '11.0',
179+
'bstack:options': {
180+
os: 'Windows',
181+
osVersion: '10',
182+
local: 'false',
183+
seleniumVersion: '3.5.2',
184+
resolution: '1366x768'
185+
}
186+
}
187+
},
188+
189+
/// ///////////////////////////////////////////////////////////////////////////////
190+
// Configuration for when using the Selenium service, either locally or remote, |
191+
// like Selenium Grid |
192+
/// ///////////////////////////////////////////////////////////////////////////////
193+
selenium: {
194+
// Selenium Server is running locally and is managed by Nightwatch
195+
selenium: {
196+
start_process: true,
197+
port: 4444,
198+
server_path: Services.seleniumServer
199+
? Services.seleniumServer.path
200+
: '',
201+
cli_args: {
202+
'webdriver.gecko.driver': Services.geckodriver
203+
? Services.geckodriver.path
204+
: '',
205+
'webdriver.chrome.driver': Services.chromedriver
206+
? Services.chromedriver.path
207+
: ''
208+
}
209+
}
210+
},
211+
212+
'selenium.chrome': {
213+
extends: 'selenium',
214+
desiredCapabilities: {
215+
browserName: 'chrome',
216+
chromeOptions: {
217+
w3c: false
218+
}
219+
}
220+
},
221+
222+
'selenium.firefox': {
223+
extends: 'selenium',
224+
desiredCapabilities: {
225+
browserName: 'firefox',
226+
'moz:firefoxOptions': {
227+
args: geckoArgs
228+
}
229+
}
230+
}
231+
}
232+
}
233+
234+
const baseSettings = deepmerge(defaultSettings, webdriverServerSettings())
235+
236+
module.exports = deepmerge(baseSettings, adaptUserSettings(userOptions))
237+
238+
function adaptUserSettings (settings) {
239+
// The path to nightwatch external globals file needs to be made absolute
240+
// if it is supplied in an additional config file, due to merging of config files
241+
if (settings.globals_path) {
242+
settings.globals_path = path.resolve(settings.globals_path)
243+
}
244+
245+
return settings
246+
}
247+
248+
function webdriverServerSettings () {
249+
if (useSelenium) {
250+
return {
251+
selenium: {
252+
start_process: true,
253+
host: '127.0.0.1',
254+
port: 4444,
255+
server_path: require('selenium-server').path,
256+
cli_args: {
257+
'webdriver.chrome.driver': Services.chromedriver.path,
258+
'webdriver.gecko.driver': Services.geckodriver.path
259+
}
260+
}
261+
}
262+
}
263+
264+
return {
265+
webdriver: {
266+
start_process: true,
267+
port: 9515,
268+
server_path: Services.chromedriver.path
269+
}
270+
}
271+
}
272+
273+
function loadServices () {
274+
try {
275+
Services.seleniumServer = require('selenium-server')
276+
} catch (err) {}
277+
278+
try {
279+
Services.chromedriver = require('chromedriver')
280+
} catch (err) {}
281+
282+
try {
283+
Services.geckodriver = require('geckodriver')
284+
} catch (err) {}
285+
}

0 commit comments

Comments
 (0)