On CI, as part of removing recursive injection of extension dependencies (T389998), I would like to add a job that runs extensions tests with solely the required extensions (requires field in extension.json). I have filed T407797 for that. To achieve that, I would need wdio-mediawiki to support skipping a test based on whether an extension is loaded (similar to MediaWikiIntegrationTestCase::markTestSkippedIfExtensionNotLoaded()).
When an extension is installed by CI, its dependencies are added but its transitive dependencies would no more be installed and tests from dependencies to fail. For example, Wikistories has tests with MinervaNeue which has a test with Cite. When disabling recursive dependencies, the MinervaNeue test with Cite fails due to the missing extension. I worked around it by having the MinervaNeue Cite test to query the MediaWiki API for installed extensions and use this.skip() in the test: https://gerrit.wikimedia.org/r/c/mediawiki/skins/MinervaNeue/+/1226850 . This code can be "upstreamed" to wdio-mediawiki.
Slightly related, I have made the same for a Cypress test of CommunityConfiguration which required CommunityConfigurationExample: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/CommunityConfiguration/+/1216756/6/cypress/e2e/ccexample.cy.ts
The code for MinervaNeue is straightforward, though it is based on wdio-mediawiki 5 which uses mwbot. From MinervaNeue - selenium: skip References tests when Cite is not loaded:
before( async function () { // References are provided by the Cite extension which might not be available await mwbot().then( ( bot ) => bot.request( { action: 'query', format: 'json', meta: 'siteinfo', siprop: 'extensions' } ).then( ( response ) => { const installedExtensions = response.query.extensions.map( ( extension ) => extension.name ); if ( !installedExtensions.includes( 'Cite' ) ) { this.skip(); } } ) );
I am imagining this code snippet can be added to wdio-mediawiki, adding support for passing the extension and it would probably need to cache the API request to avoid redoing it each time the function is called.