Skip to content

Run browser tests with Fresh

Releasev0.35.0 · cfeceb67

Watch it in action

A recorded Fresh browser test

Fresh runs Node.js and browser tools in a container, with your MediaWiki checkout mounted at /var/www/html/w. Run the commands below from the checkout directory after installing a wiki.

Terminal window
mw dev mediawiki fresh npm ci
mw dev mediawiki fresh npm run selenium-test -- -- --spec tests/selenium/specs/recentchanges.js

For connection defaults, argument forwarding, and recording behavior, read mw dev mediawiki fresh --help. Override the development account when testing another user, as shown below.

To inspect the container or override an environment variable for one command:

Terminal window
mw dev mediawiki fresh bash
mw dev mediawiki fresh MEDIAWIKI_USER=OtherAdmin npm run selenium-test -- -- --spec tests/selenium/specs/recentchanges.js

With a checkout that supports wdio-mediawiki video recording, use the shortcut after installing dependencies with mw dev mediawiki fresh npm ci:

Terminal window
mw dev mediawiki fresh record tests/selenium/specs/recentchanges.js

Omit the spec to record the full Selenium suite, running one spec at a time:

Terminal window
mw dev mediawiki fresh record

The explicit equivalent for a single spec is:

Terminal window
mw dev mediawiki fresh npm run selenium-test -- -- --recordVideo --useBrowserHeadless=false --maxInstances=1 --spec tests/selenium/specs/recentchanges.js

The bundled browser image provides Xvfb and ffmpeg. The runner starts its virtual display and recorder automatically; no manual Xvfb session is needed. Recording needs a non-headless browser inside that virtual display, so keep --useBrowserHeadless=false.

The first -- passes the remaining flags through the CLI; the second forwards them through npm to WebdriverIO. Keep both when passing test-runner flags.

Videos and reports normally appear in tests/selenium/log/ in your host checkout. Check for a newly written .mp4 file after the run. A project’s WebdriverIO configuration can change the output directory; LOG_DIR sets the default runner’s log directory. Older checkouts may lack recording support or require their own setup; consult their Selenium README.

Recording is opt-in. Omit the recording options for normal browser tests. See Fresh and your checkout’s tests/selenium/README.md for more options.


Read this guide offline with mw help guides dev fresh.

Report an issue with this page

Report a documentation issue

The report includes this page’s link, section and documentation version.

Review and submit on Phabricator, or run the command using your saved CLI profile. The command asks before creating the task.