Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix(tests): Fixes session creation when using '--spec' arg.

damencho3c41791ed118
diff --git a/tests/wdio.conf.ts b/tests/wdio.conf.ts
index 9a5c67a4ba..942de30711 100644
--- a/tests/wdio.conf.ts
+++ b/tests/wdio.conf.ts
@@ -70,7 +70,7 @@ const specs = [
*/
function generateCapabilitiesFromSpecs(): { capabilities: Record<string, any>; excludedSpecs: string[]; } {
const allSpecFiles: string[] = [];
- const browsers = [ 'p1', 'p2', 'p3', 'p4', 'p5', 'p6' ];
+ const allBrowsers = [ 'p1', 'p2', 'p3', 'p4', 'p5', 'p6' ];
const excludedSpecs: string[] = [];
for (const pattern of specs) {
@@ -85,15 +85,73 @@ function generateCapabilitiesFromSpecs(): { capabilities: Record<string, any>; e
// Import TestProperties to access the populated registry
const { testProperties } = require('./helpers/TestProperties');
+ // Detect if specific spec files are targeted via --spec CLI argument (e.g. npm run test-single).
+ // When targeted, only create capabilities for the browsers those specs actually need.
+ const targetedSpecFiles: string[] = [];
+
+ for (let i = 0; i < process.argv.length; i++) {
+ if (process.argv[i] === '--spec') {
+ // Collect all consecutive non-flag arguments after --spec (wdio accepts space-separated specs).
+ let j = i + 1;
+
+ while (j < process.argv.length && !process.argv[j].startsWith('--')) {
+ process.argv[j].split(',').forEach(f => {
+ const normalized = f.trim().replace(/\\/g, '/');
+ // Try exact resolution first, then fall back to case-insensitive suffix matching
+ // (macOS filesystem is case-insensitive but string comparison is not).
+ const resolved = path.resolve(normalized);
+ const resolvedLower = resolved.toLowerCase();
+ const normalizedLower = normalized.toLowerCase();
+ const match = allSpecFiles.find(sf => {
+ const sfNormalized = sf.replace(/\\/g, '/');
+
+ return sfNormalized === resolved.replace(/\\/g, '/')
+ || sfNormalized.toLowerCase() === resolvedLower.replace(/\\/g, '/')
+ || sfNormalized.toLowerCase().endsWith(`/${normalizedLower}`);
+ });
+
+ if (match) {
+ targetedSpecFiles.push(match);
+ } else {
+ console.warn(`[wdio] --spec file not found in spec list: ${f}`);
+ }
+ });
+ j++;
+ }
+ i = j - 1;
+ }
+ }
+
+ console.log(`[wdio] process.argv: ${process.argv.join(' ')}`);
+ console.log(`[wdio] targeted specs: ${targetedSpecFiles.join(', ') || '(all)'}`);
+
+ const scopedFiles = targetedSpecFiles.length > 0 ? targetedSpecFiles : allSpecFiles;
+ const requiredBrowsers = new Set<string>();
+
+ for (const file of scopedFiles) {
+ const props = testProperties[file];
+
+ if (props?.useJaas && !testsConfig.jaas.enabled) {
+ continue;
+ }
+ if (props?.usesBrowsers) {
+ props.usesBrowsers.forEach((b: string) => requiredBrowsers.add(b));
+ } else {
+ requiredBrowsers.add('p1');
+ }
+ }
+
+ // Preserve the predefined browser order; fall back to all browsers if nothing was determined.
+ const browsers = requiredBrowsers.size > 0
+ ? allBrowsers.filter(b => requiredBrowsers.has(b))
+ : allBrowsers;
+
// Determine which browsers need which exclusions
- const browserExclusions: Record<string, Set<string>> = {
- p1: new Set(),
- p2: new Set(),
- p3: new Set(),
- p4: new Set(),
- p5: new Set(),
- p6: new Set()
- };
+ const browserExclusions: Record<string, Set<string>> = {};
+
+ browsers.forEach(b => {
+ browserExclusions[b] = new Set();
+ });
for (const file of allSpecFiles) {
const props = testProperties[file];
@@ -232,7 +290,7 @@ export const config: WebdriverIO.MultiremoteConfig = {
.replace(/\//g, '-');
const testProperties = await getTestProperties(testFilePath);
- console.log(`Running test: ${testName} via worker: ${cid}`);
+ console.log(`Running test: ${testName} via worker: ${cid} browser instances:${multiremotebrowser.instances.length}`);
const globalAny: any = global;
diff --git a/tests/wdio.grid.conf.ts b/tests/wdio.grid.conf.ts
index 7402138292..97b8d45369 100644
--- a/tests/wdio.grid.conf.ts
+++ b/tests/wdio.grid.conf.ts
@@ -17,14 +17,10 @@ const mergedConfig = {
path: gridUrl.pathname
};
-mergedConfig.capabilities.p1.capabilities['goog:chromeOptions'].args
- = updateRemoteResource(mergedConfig.capabilities.p1.capabilities['goog:chromeOptions'].args);
-mergedConfig.capabilities.p2.capabilities['goog:chromeOptions'].args
- = updateRemoteResource(mergedConfig.capabilities.p2.capabilities['goog:chromeOptions'].args);
-mergedConfig.capabilities.p3.capabilities['goog:chromeOptions'].args
- = updateRemoteResource(mergedConfig.capabilities.p3.capabilities['goog:chromeOptions'].args);
-mergedConfig.capabilities.p4.capabilities['goog:chromeOptions'].args
- = updateRemoteResource(mergedConfig.capabilities.p4.capabilities['goog:chromeOptions'].args);
+Object.keys(mergedConfig.capabilities).forEach(browser => {
+ mergedConfig.capabilities[browser].capabilities['goog:chromeOptions'].args
+ = updateRemoteResource(mergedConfig.capabilities[browser].capabilities['goog:chromeOptions'].args);
+});
export const config = mergedConfig;