Selenium/How-to/Set environment variables

From mediawiki.org

The test suite needs to know the address of the MediaWiki server you want to test against, and what user it should log in as.

Depending on how you installed MediaWiki, this might be automatically handled for you already. If you encounter Error: MW_SERVER not defined then you may need to do a one-time step to set some environment variables, which allows our test suite to discover this information.

The below shows two methods: set environment variables using the export command on the terminal, or store them in a .env file. Both options do the same thing. It is up to you do decide which one to use.

When using environment variables in the terminal, you can make it easier for next time, by setting them from a shell configuration file (~/.bash_profile, ~/.zshrc...). That means the variables are always available from any terminal session.

When installing MediaWiki-Docker, you will have already created an .env, and there is no need to set environment variables.
If you encounter Error: MW_SERVER not defined, there might be a different problem. Ask for help!

Environment variables in terminal:

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

Or create a .env file at the root of the MediaWiki repository:

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

Environment variables in terminal:

# Target Cli/docker
export MW_SERVER=http://default.mediawiki.mwdd.localhost:8080
export MW_SCRIPT_PATH=/w
export MEDIAWIKI_USER=admin
export MEDIAWIKI_PASSWORD=mwddpassword

Environment variables in terminal:

# Target MediaWiki-Docker-Dev
export MW_SERVER=http://default.web.mw.localhost:8080
export MW_SCRIPT_PATH=/mediawiki
export MEDIAWIKI_USER=Admin
export MEDIAWIKI_PASSWORD=dockerpass

Environment variables in terminal:

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

You can also run the test suite of your local MediaWiki copy against against a different MediaWiki site. To do this, override the environment variables in terminal. (Don't worry, this is temporary! When you close the terminal, this override will not be saved.)

# Target Beta cluster
export MW_SERVER=https://en.wikipedia.beta.wmflabs.org
export MW_SCRIPT_PATH=/w
export MEDIAWIKI_USER=mediawiki_user
export MEDIAWIKI_PASSWORD=mediawiki_password

Replace mediawiki_user and mediawiki_password with your username and password.