Page MenuHomePhabricator

Running npm run selenium-test in core locally throws Cannot read properties of undefined error
Closed, ResolvedPublicBUG REPORT

Description

Running npm run selenium-test locally on my machine gives the following error:

2025-10-21T06:22:08.254Z ERROR @wdio/cli:utils: Error in onCompleteHook: TypeError: Cannot read properties of undefined (reading 'project')
    at writeAllProjectMetrics (file:///Users/phedenskog/git/core/tests/selenium/wdio-mediawiki/PrometheusFileReporter.js:257:44)
    at Object.onComplete (file:///Users/phedenskog/git/core/tests/selenium/wdio-mediawiki/wdio-defaults.conf.js:244:3)
    at file:///Users/phedenskog/git/core/node_modules/@wdio/cli/build/index.js:378:13
    at Array.map (<anonymous>)
    at runOnCompleteHook (file:///Users/phedenskog/git/core/node_modules/@wdio/cli/build/index.js:376:37)
    at #runOnCompleteHook (file:///Users/phedenskog/git/core/node_modules/@wdio/cli/build/index.js:927:37)
    at Launcher.run (file:///Users/phedenskog/git/core/node_modules/@wdio/cli/build/index.js:892:47)
    at async Module.run (file:///Users/phedenskog/git/core/node_modules/@wdio/cli/build/index.js:1648:16)

I think this must have been introduced with the 6.0.0 release?

Event Timeline

Ok this comes from when you cannot download chromedriver and no tests runs. I can add a check so we don't try to store the file if no tests runs.

Change #1197391 had a related patch set uploaded (by Phedenskog; author: Phedenskog):

[mediawiki/core@master] selenium: Only write Promethues metrics if test runs

https://gerrit.wikimedia.org/r/1197391

I think this must have been introduced with the 6.0.0 release?

I don’t think so, I’m also encountering it in this Wikibase change that’s just upgrading to wdio-mediawiki v4. It might be a different underlying issue that causes the metricsDir to not contain any specs-*.json files?

Do you know if it would be possible to backport the fix to wdio-mediawiki v4 and v5? Or to work around it in another way on those versions?

Workaround for wdio.conf.js (where config is imported from wdio-mediawiki/wdio-defaults.conf.js):

onComplete() {
	try {
		return config.onComplete();
	} catch ( _ ) {
		// ignore TypeError: Cannot read properties of undefined (reading 'project') [T407831]
		// remove this onComplete() override again once we’re on a version of wdio-mediawiki
		// with a fix (maybe 6.0.1?)
	}
}

Change #1197391 merged by jenkins-bot:

[mediawiki/core@master] selenium: Only write Promethues metrics if test runs

https://gerrit.wikimedia.org/r/1197391

Peter moved this task from In Review to Done on the Test Platform (Taormina Three 18) board.

Change #1211178 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/Wikibase@master] WIP: Remove workaround for T407831

https://gerrit.wikimedia.org/r/1211178