Skip to content

Commit a1af9b1

Browse files
kiakingktsn
authored andcommitted
#1647 Remove PhantomJS from E2E test, and use Chrom Headless Webdriver (#1648)
* Remove PhantonJS from E2E test, and use Chrom Headless Webdriver * Update Nightwatch * Optimise Nighteatch config
1 parent d3979fd commit a1af9b1

File tree

6 files changed

+675
-454
lines changed

6 files changed

+675
-454
lines changed

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"babel-plugin-transform-object-rest-spread": "^6.23.0",
4646
"babel-polyfill": "^6.22.0",
4747
"babel-preset-env": "^1.5.1",
48-
"chromedriver": "^2.45.0",
48+
"chromedriver": "^78.0.1",
4949
"cross-env": "^5.2.0",
5050
"cross-spawn": "^6.0.5",
5151
"css-loader": "^2.1.0",
@@ -54,13 +54,11 @@
5454
"express": "^4.14.1",
5555
"jasmine": "2.8.0",
5656
"jasmine-core": "2.8.0",
57-
"nightwatch": "^0.9.12",
57+
"nightwatch": "^1.3.1",
5858
"nightwatch-helpers": "^1.2.0",
59-
"phantomjs-prebuilt": "^2.1.14",
6059
"rollup": "^1.1.0",
6160
"rollup-plugin-buble": "^0.19.6",
6261
"rollup-plugin-replace": "^2.1.0",
63-
"selenium-server": "^2.53.1",
6462
"terser": "^3.17.0",
6563
"todomvc-app-css": "^2.1.0",
6664
"typescript": "^3.7.2",

test/e2e/nightwatch.config.js

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,14 @@ module.exports = {
55
'custom_commands_path': ['node_modules/nightwatch-helpers/commands'],
66
'custom_assertions_path': ['node_modules/nightwatch-helpers/assertions'],
77

8-
'selenium': {
8+
'webdriver': {
99
'start_process': true,
10-
'server_path': require('selenium-server').path,
11-
'host': '127.0.0.1',
12-
'port': 4444,
13-
'cli_args': {
14-
'webdriver.chrome.driver': require('chromedriver').path
15-
}
10+
'port': 9515,
11+
'server_path': require('chromedriver').path
1612
},
1713

1814
'test_settings': {
1915
'default': {
20-
'selenium_port': 4444,
21-
'selenium_host': 'localhost',
2216
'silent': true,
2317
'screenshots': {
2418
'enabled': true,
@@ -32,16 +26,10 @@ module.exports = {
3226
'desiredCapabilities': {
3327
'browserName': 'chrome',
3428
'javascriptEnabled': true,
35-
'acceptSslCerts': true
36-
}
37-
},
38-
39-
'phantomjs': {
40-
'desiredCapabilities': {
41-
'browserName': 'phantomjs',
42-
'javascriptEnabled': true,
4329
'acceptSslCerts': true,
44-
'phantomjs.binary.path': require('phantomjs-prebuilt').path
30+
'chromeOptions': {
31+
'args': ['--headless']
32+
}
4533
}
4634
}
4735
}

test/e2e/runner.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,12 @@ if (args.indexOf('--config') === -1) {
99
args = args.concat(['--config', 'test/e2e/nightwatch.config.js'])
1010
}
1111
if (args.indexOf('--env') === -1) {
12-
args = args.concat(['--env', 'phantomjs'])
12+
args = args.concat(['--env', 'chrome'])
1313
}
1414
var i = args.indexOf('--test')
1515
if (i > -1) {
1616
args[i + 1] = 'test/e2e/specs/' + args[i + 1]
1717
}
18-
if (args.indexOf('phantomjs') > -1) {
19-
process.env.PHANTOMJS = true
20-
}
2118

2219
var runner = spawn('./node_modules/.bin/nightwatch', args, {
2320
stdio: 'inherit'

test/e2e/specs/cart.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = {
2020
.assert.containsText('.cart', 'H&M T-Shirt White - $10.99 x 1')
2121
.assert.containsText('.cart', 'Total: $1,011.01')
2222
.click('.cart button')
23-
.waitFor(120)
23+
.waitFor(200)
2424
.assert.containsText('.cart', 'Please add some products to cart')
2525
.assert.containsText('.cart', 'Total: $0.00')
2626
.assert.containsText('.cart', 'Checkout successful')

test/e2e/specs/todomvc.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ module.exports = {
105105
.dblClick('.todo:nth-child(1) label')
106106
.assert.count('.todo.editing', 1)
107107
.assert.focused('.todo:nth-child(1) .edit')
108-
.clearValue('.todo:nth-child(1) .edit')
108+
deleteValue('.todo:nth-child(1) .edit', 'test2')
109109
.setValue('.todo:nth-child(1) .edit', 'edited!')
110110
.click('footer') // blur
111111
.assert.count('.todo.editing', 0)
@@ -114,14 +114,15 @@ module.exports = {
114114
// editing triggered by enter
115115
browser
116116
.dblClick('.todo label')
117+
deleteValue('.todo:nth-child(1) .edit', 'edited!')
117118
.enterValue('.todo:nth-child(1) .edit', 'edited again!')
118119
.assert.count('.todo.editing', 0)
119120
.assert.containsText('.todo:nth-child(1) label', 'edited again!')
120121

121122
// cancel
122123
browser
123124
.dblClick('.todo label')
124-
.clearValue('.todo:nth-child(1) .edit')
125+
deleteValue('.todo:nth-child(1) .edit', 'edited again!')
125126
.setValue('.todo:nth-child(1) .edit', 'edited!')
126127
.trigger('.todo:nth-child(1) .edit', 'keyup', 27)
127128
.assert.count('.todo.editing', 0)
@@ -130,6 +131,7 @@ module.exports = {
130131
// empty value should remove
131132
browser
132133
.dblClick('.todo label')
134+
deleteValue('.todo:nth-child(1) .edit', 'edited again!')
133135
.enterValue('.todo:nth-child(1) .edit', ' ')
134136
.assert.count('.todo', 3)
135137

@@ -150,5 +152,9 @@ module.exports = {
150152
.moveToElement('.todo:nth-child(' + n + ')', 10, 10)
151153
.click('.todo:nth-child(' + n + ') .destroy')
152154
}
155+
156+
function deleteValue (el, text) {
157+
return browser.setValue(el, text.split('').map(() => '\u0008'))
158+
}
153159
}
154160
}

0 commit comments

Comments
 (0)