selenium: Run wdio directly without grunt
authorTimo Tijhof <krinklemail@gmail.com>
Sat, 21 Apr 2018 01:10:56 +0000 (02:10 +0100)
committerKrinkle <krinklemail@gmail.com>
Mon, 30 Apr 2018 21:54:15 +0000 (21:54 +0000)
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

Gruntfile.js
package.json
tests/selenium/.eslintrc.json
tests/selenium/README.md
tests/selenium/selenium.sh

index 69a123c..898b48f 100644 (file)
@@ -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 () {
index b9a7ccc..7b779a6 100644 (file)
@@ -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",
index 85fc310..e39226c 100644 (file)
@@ -9,6 +9,6 @@
                "browser": false
        },
        "rules":{
-               "no-console":0
+               "no-console": 0
        }
 }
index b15d407..274eb14 100644 (file)
@@ -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:
 
index 6b71019..4a5c254 100755 (executable)
@@ -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() {