Skip to content

Commit

Permalink
#1647 Remove PhantomJS from E2E test, and use Chrom Headless Webdriver (
Browse files Browse the repository at this point in the history
#1648)

* Remove PhantonJS from E2E test, and use Chrom Headless Webdriver

* Update Nightwatch

* Optimise Nighteatch config
  • Loading branch information
kiaking authored and ktsn committed Dec 25, 2019
1 parent d3979fd commit a1af9b1
Show file tree
Hide file tree
Showing 6 changed files with 675 additions and 454 deletions.
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-polyfill": "^6.22.0",
"babel-preset-env": "^1.5.1",
"chromedriver": "^2.45.0",
"chromedriver": "^78.0.1",
"cross-env": "^5.2.0",
"cross-spawn": "^6.0.5",
"css-loader": "^2.1.0",
Expand All @@ -54,13 +54,11 @@
"express": "^4.14.1",
"jasmine": "2.8.0",
"jasmine-core": "2.8.0",
"nightwatch": "^0.9.12",
"nightwatch": "^1.3.1",
"nightwatch-helpers": "^1.2.0",
"phantomjs-prebuilt": "^2.1.14",
"rollup": "^1.1.0",
"rollup-plugin-buble": "^0.19.6",
"rollup-plugin-replace": "^2.1.0",
"selenium-server": "^2.53.1",
"terser": "^3.17.0",
"todomvc-app-css": "^2.1.0",
"typescript": "^3.7.2",
Expand Down
24 changes: 6 additions & 18 deletions test/e2e/nightwatch.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,14 @@ module.exports = {
'custom_commands_path': ['node_modules/nightwatch-helpers/commands'],
'custom_assertions_path': ['node_modules/nightwatch-helpers/assertions'],

'selenium': {
'webdriver': {
'start_process': true,
'server_path': require('selenium-server').path,
'host': '127.0.0.1',
'port': 4444,
'cli_args': {
'webdriver.chrome.driver': require('chromedriver').path
}
'port': 9515,
'server_path': require('chromedriver').path
},

'test_settings': {
'default': {
'selenium_port': 4444,
'selenium_host': 'localhost',
'silent': true,
'screenshots': {
'enabled': true,
Expand All @@ -32,16 +26,10 @@ module.exports = {
'desiredCapabilities': {
'browserName': 'chrome',
'javascriptEnabled': true,
'acceptSslCerts': true
}
},

'phantomjs': {
'desiredCapabilities': {
'browserName': 'phantomjs',
'javascriptEnabled': true,
'acceptSslCerts': true,
'phantomjs.binary.path': require('phantomjs-prebuilt').path
'chromeOptions': {
'args': ['--headless']
}
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions test/e2e/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@ if (args.indexOf('--config') === -1) {
args = args.concat(['--config', 'test/e2e/nightwatch.config.js'])
}
if (args.indexOf('--env') === -1) {
args = args.concat(['--env', 'phantomjs'])
args = args.concat(['--env', 'chrome'])
}
var i = args.indexOf('--test')
if (i > -1) {
args[i + 1] = 'test/e2e/specs/' + args[i + 1]
}
if (args.indexOf('phantomjs') > -1) {
process.env.PHANTOMJS = true
}

var runner = spawn('./node_modules/.bin/nightwatch', args, {
stdio: 'inherit'
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/specs/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = {
.assert.containsText('.cart', 'H&M T-Shirt White - $10.99 x 1')
.assert.containsText('.cart', 'Total: $1,011.01')
.click('.cart button')
.waitFor(120)
.waitFor(200)
.assert.containsText('.cart', 'Please add some products to cart')
.assert.containsText('.cart', 'Total: $0.00')
.assert.containsText('.cart', 'Checkout successful')
Expand Down
10 changes: 8 additions & 2 deletions test/e2e/specs/todomvc.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ module.exports = {
.dblClick('.todo:nth-child(1) label')
.assert.count('.todo.editing', 1)
.assert.focused('.todo:nth-child(1) .edit')
.clearValue('.todo:nth-child(1) .edit')
deleteValue('.todo:nth-child(1) .edit', 'test2')
.setValue('.todo:nth-child(1) .edit', 'edited!')
.click('footer') // blur
.assert.count('.todo.editing', 0)
Expand All @@ -114,14 +114,15 @@ module.exports = {
// editing triggered by enter
browser
.dblClick('.todo label')
deleteValue('.todo:nth-child(1) .edit', 'edited!')
.enterValue('.todo:nth-child(1) .edit', 'edited again!')
.assert.count('.todo.editing', 0)
.assert.containsText('.todo:nth-child(1) label', 'edited again!')

// cancel
browser
.dblClick('.todo label')
.clearValue('.todo:nth-child(1) .edit')
deleteValue('.todo:nth-child(1) .edit', 'edited again!')
.setValue('.todo:nth-child(1) .edit', 'edited!')
.trigger('.todo:nth-child(1) .edit', 'keyup', 27)
.assert.count('.todo.editing', 0)
Expand All @@ -130,6 +131,7 @@ module.exports = {
// empty value should remove
browser
.dblClick('.todo label')
deleteValue('.todo:nth-child(1) .edit', 'edited again!')
.enterValue('.todo:nth-child(1) .edit', ' ')
.assert.count('.todo', 3)

Expand All @@ -150,5 +152,9 @@ module.exports = {
.moveToElement('.todo:nth-child(' + n + ')', 10, 10)
.click('.todo:nth-child(' + n + ') .destroy')
}

function deleteValue (el, text) {
return browser.setValue(el, text.split('').map(() => '\u0008'))
}
}
}
Loading

0 comments on commit a1af9b1

Please sign in to comment.