From: Timo Tijhof Date: Sat, 21 Apr 2018 01:10:56 +0000 (+0100) Subject: selenium: Run wdio directly without grunt X-Git-Tag: 1.34.0-rc.0~5547^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/modifier.php?a=commitdiff_plain;h=810afd33e003f7bdfd8a7802cfb72cc6797f49e2;p=lhc%2Fweb%2Fwiklou.git selenium: Run wdio directly without grunt Doesn't seem to add anything, except complexity. This has the benefit of matching more closely the way the README recommends running individual tests. Also add a check for 'chromedriver' before running it. Normally the -e and pipefail would suffice, but because it runs in the background, the error can be buried, hard to find, or even not cause exit code to be set properly. Thus, do a simple 'hash' check that will print a useful command and exit cleanly. Before: > $ something & > [1] 57922 > -bash: something: command not found > [1]+ Exit 127 something > $ echo $? > 0 After: > $ hash something > -bash: hash: something: not found > (exit: 1) $ echo $? > 1 Change-Id: Id95f18927b5443defe679a77a82c5cbdd127c716 --- diff --git a/Gruntfile.js b/Gruntfile.js index 69a123cc9f..898b48f2df 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -13,7 +13,6 @@ module.exports = function ( grunt ) { grunt.loadNpmTasks( 'grunt-jsonlint' ); grunt.loadNpmTasks( 'grunt-karma' ); grunt.loadNpmTasks( 'grunt-stylelint' ); - grunt.loadNpmTasks( 'grunt-webdriver' ); karmaProxy[ wgScriptPath ] = { target: wgServer + wgScriptPath, @@ -104,15 +103,7 @@ module.exports = function ( grunt ) { return require( 'path' ).join( dest, src.replace( 'resources/', '' ) ); } } - }, - - // Configure WebdriverIO task - webdriver: { - test: { - configFile: './tests/selenium/wdio.conf.js' - } } - } ); grunt.registerTask( 'assert-mw-env', function () { diff --git a/package.json b/package.json index b9a7cccf8b..7b779a6795 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "doc": "jsduck", "postdoc": "grunt copy:jsduck", "selenium": "./tests/selenium/selenium.sh", - "selenium-test": "grunt webdriver:test" + "selenium-test": "wdio ./tests/selenium/wdio.conf.js" }, "devDependencies": { "bluebird": "3.5.1", @@ -21,7 +21,6 @@ "grunt-jsonlint": "1.1.0", "grunt-karma": "2.0.0", "grunt-stylelint": "0.10.0", - "grunt-webdriver": "2.0.3", "karma": "1.7.1", "karma-chrome-launcher": "2.2.0", "karma-firefox-launcher": "1.0.1", diff --git a/tests/selenium/.eslintrc.json b/tests/selenium/.eslintrc.json index 85fc310708..e39226c4ac 100644 --- a/tests/selenium/.eslintrc.json +++ b/tests/selenium/.eslintrc.json @@ -9,6 +9,6 @@ "browser": false }, "rules":{ - "no-console":0 + "no-console": 0 } } diff --git a/tests/selenium/README.md b/tests/selenium/README.md index b15d4073dc..274eb14360 100644 --- a/tests/selenium/README.md +++ b/tests/selenium/README.md @@ -5,9 +5,8 @@ - [Chrome](https://www.google.com/chrome/) - [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/) - [Node.js](https://nodejs.org/en/) -- [MediaWiki-Vagrant](https://www.mediawiki.org/wiki/MediaWiki-Vagrant) -Set up MediaWiki-Vagrant: +If using MediaWiki-Vagrant: cd mediawiki/vagrant vagrant up @@ -24,7 +23,7 @@ Set up MediaWiki-Vagrant: By default, Chrome will run in headless mode. If you want to see Chrome, set DISPLAY environment variable to any value: - DISPLAY=:1 npm run selenium + DISPLAY=1 npm run selenium To run only one file (for example page.js), you first need to spawn the chromedriver: diff --git a/tests/selenium/selenium.sh b/tests/selenium/selenium.sh index 6b71019b28..4a5c254839 100755 --- a/tests/selenium/selenium.sh +++ b/tests/selenium/selenium.sh @@ -1,5 +1,8 @@ #!/usr/bin/env bash set -euo pipefail +# Check the command before running in background so +# that it can actually fail and have a descriptive error +hash chromedriver chromedriver --url-base=/wd/hub --port=4444 & # Make sure it is killed to prevent file descriptors leak function kill_chromedriver() {