Selenium/How-to/Run tests targeting MediaWiki-Vagrant

From mediawiki.org
Jump to navigation Jump to search

For this example, we will not enable any roles and we will use MediaWiki Core.


Advantages[edit]

Running Selenium tests targeting MediaWiki-Vagrant machine has several advantages:

  • It will be fast, since the target machine is local. MediaWiki Core Selenium test run takes about 2 minutes on my machine. (As of September 2019.)
  • After everything is set up, you do not need internet connection.
  • Debugging failed tests will be easier, since you are able to see the browser. See Selenium/How-to/Make the browser visible.
  • You are probably already familiar with MediaWiki-Vagrant and have it installed.

Disadvantages[edit]

  • You might not be familiar with MediaWiki-Vagrant, so you will have to learn how to install and use yet another tool.
  • You will have to install Vagrant, MediaWiki-Vagrant and their dependencies on your machine.
  • You will be executing over 900 JavaScript packages (as of August 2019) directly on your machine with access to all personal/work files.

Set up MediaWiki-Vagrant[edit]

Boot the machine[edit]

vagrant up

Go to mediawiki folder[edit]

cd mediawiki

Install dependencies[edit]

Depending on your operating system, installing dependencies will be different.

Chrome[edit]

Node.js[edit]

  • Install Node.js.
  • Install required npm packages.
Warning Warning: Running npm ci is not safe. See How to protect yourself from npm.


npm ci

Environment variables[edit]

Ensure the following environment variables are set. Either run this manually from the terminal or, to make it easier for next time, set them from shell configuration file (~/.bash_profile, ~/.zshrc...) which means the variables are always available from any terminal session:

# Target MediaWiki-Vagrant
export MW_SERVER=http://localhost:8080
export MW_SCRIPT_PATH=/w
export MEDIAWIKI_USER=Admin
export MEDIAWIKI_PASSWORD=vagrant

If you prefer, you can create an .env file instead (in MediaWiki Core folder), with this contents.

# Target MediaWiki-Vagrant
MW_SERVER=http://localhost:8080
MW_SCRIPT_PATH=/w
MEDIAWIKI_USER=Admin
MEDIAWIKI_PASSWORD=vagrant

Run Selenium tests[edit]

npm run selenium-test

suspend or halt the machine[edit]

vagrant suspend

or

vagrant halt