Selenium/How-to/Run tests targeting MediaWiki-Docker using Fresh

From MediaWiki.org
Jump to navigation Jump to search

This page describes how to run Selenium tests locally on your development install of MediaWiki. This tutorial is based on the setup from MediaWiki-Docker.

Advantages[edit]

  • It will be fast, since the target machine is local. MediaWiki core Selenium test run takes about 2 minutes on my machine. (As of October 2019.)
  • Works without an internet connection.
  • Doesn't require installing Vagrant.
  • Doesn't require installing ChromeDriver or FFmpeg (compared to bare installs).
  • Doesn't require executing npm packages directly on your machine (which is scary).

Disadvantages[edit]

  • You need to have Docker installed.

Prerequisites[edit]

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:

export MW_SERVER=http://localhost:8080
export MW_SCRIPT_PATH=/
export MEDIAWIKI_USER=Admin
export MEDIAWIKI_PASSWORD=dockerpass

Run Selenium tests[edit]

Next, navigate to where you have the MediaWiki core repository and start a Fresh session (let it see environment variables, and grant networking to access for your MediaWiki install):

you:~$ cd mediawiki
you:mediawiki$ fresh-node -env -net
  env: MW_*, MEDIAWIKI_*
  net: expose host

  🌱  Fresh!
nobody@docker-desktop:/mediawiki$

The first time (or after updating MediaWiki), install the npm packages used by MediaWiki's browser tests:

nobody@docker-desktop:/mediawiki$ npm ci

  added 934 packages in 51.85s

And finally, run the tests:

nobody@docker-desktop:/mediawiki$ npm run selenium
  Starting ChromeDriver
  wdio ./tests/selenium/wdio.conf.js

  14 passing (281.40s)