wiki.techinc.nl/tests/selenium
Timo Tijhof 46586a243c selenium: Replace ES5 one-var assignments with const/let per line
The one-var rule only applies to 'var' where it matters that we
don't let the engine implicitly hoist variables leading to
confusing code that may be unsafe to refactor in a straight-forward
manner.

This doesn't apply to ES6 const and let. While I updated the
rule in 1955a8aa5 to allow ES6, I did not enforce it. Fixed now.
When assigning a value, each assignment should be its own
statement (disallow awkward comma separated assignments).
When not assigning a value, and the lines are next to each other,
they should be in one statement. This makes sense for this small
directory and might make sense to propose for the wikimedia preset
at some point.

Note that the rule I added was not required to make the build
pass. The changes I made are allowed by default by the wikimedia
preset for es6+. The rule I added disallows the previous way.

Change-Id: I26cda095a8a4589084e36273038877f2dd1fc50b
2019-10-01 02:18:19 +00:00
..
pageobjects selenium: Replace ES5 one-var assignments with const/let per line 2019-10-01 02:18:19 +00:00
specs selenium: Replace ES5 one-var assignments with const/let per line 2019-10-01 02:18:19 +00:00
wdio-mediawiki selenium: Replace ES5 one-var assignments with const/let per line 2019-10-01 02:18:19 +00:00
.eslintrc.json selenium: Replace ES5 one-var assignments with const/let per line 2019-10-01 02:18:19 +00:00
README.md Selenium: record video of every test 2018-10-16 22:07:22 +00:00
selenium.sh Use wd/hub not /wd/hub in selenium.sh 2018-06-13 11:56:15 +00:00
wdio.conf.js selenium: Replace ES5 one-var assignments with const/let per line 2019-10-01 02:18:19 +00:00

Selenium tests

Prerequisites

If using MediaWiki-Vagrant:

cd mediawiki/vagrant
vagrant up

Installation

cd mediawiki
npm install

Usage

npm run selenium

There are three supported modes of running the tests:

  • Headless. It's the default. You will not see the browser while tests are running because it's running in a headless mode. This mode should run fine on all supported platforms.
  • Headless recording. Set DISPLAY environment variable to a value that starts with colon (:) and video of each test will be recorded. Browser will run headless. Recording videos works only on Linux.
  • Visible. If you want to see the browser, set DISPLAY environment variable to any value that does not start with colon. This mode will not work in a headless environment like MediaWiki-Vagrant.

Example recording session:

sudo apt-get install chromedriver ffmpeg xvfb
export DISPLAY=:94
Xvfb "$DISPLAY" -screen 0 1280x1024x24 &
npm run selenium

Example visible session:

DISPLAY=1 npm run selenium

To run only one test (for example specs/page.js), you first need to start Chromedriver:

chromedriver --url-base=wd/hub --port=4444

Then, in another terminal:

npm run selenium-test -- --spec tests/selenium/specs/page.js

You can also filter specific cases, for ones that contain the string 'preferences':

npm run selenium-test -- tests/selenium/specs/user.js --mochaOpts.grep preferences

The runner reads the configuration from wdio.conf.js. The defaults target a MediaWiki-Vagrant installation on http://127.0.0.1:8080 with a user "Admin" and password "vagrant". Those settings can be overridden using environment variables:

  • MW_SERVER: to be set to the value of your $wgServer
  • MW_SCRIPT_PATH: ditto with $wgScriptPath
  • MEDIAWIKI_USER: username of an account that can create users on the wiki
  • MEDIAWIKI_PASSWORD: password for above user

Example:

MW_SERVER=http://example.org MW_SCRIPT_PATH=/dev/w npm run selenium

Further reading