Run browser tests with Fresh
Releasev0.35.0 · cfeceb67
Watch it in action
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.
Install dependencies and run a test
Section titled “Install dependencies and run a test”mw dev mediawiki fresh npm cimw dev mediawiki fresh npm run selenium-test -- -- --spec tests/selenium/specs/recentchanges.jsFor 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:
mw dev mediawiki fresh bashmw dev mediawiki fresh MEDIAWIKI_USER=OtherAdmin npm run selenium-test -- -- --spec tests/selenium/specs/recentchanges.jsRecord a Selenium video
Section titled “Record a Selenium video”With a checkout that supports wdio-mediawiki video recording, use the shortcut after installing dependencies with mw dev mediawiki fresh npm ci:
mw dev mediawiki fresh record tests/selenium/specs/recentchanges.jsOmit the spec to record the full Selenium suite, running one spec at a time:
mw dev mediawiki fresh recordThe explicit equivalent for a single spec is:
mw dev mediawiki fresh npm run selenium-test -- -- --recordVideo --useBrowserHeadless=false --maxInstances=1 --spec tests/selenium/specs/recentchanges.jsThe 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.
Page views: —Sessions: —