froth-webdriverio-framework 7.0.77 → 7.0.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -410,66 +410,58 @@ async function getBrowserStackCapabilities(baseCaps) {
410
410
  process.env.PLATFORM !== 'browserstacklocal'
411
411
  ) {
412
412
  return baseCaps;
413
- } /** 🔍 Print raw capabilities first */
414
-
413
+ }
415
414
 
416
415
  console.log('🟡 Raw Capabilities (Before):');
417
416
  console.log(JSON.stringify(baseCaps, null, 2));
418
- return baseCaps.map(async (capabilities) => {
419
- const bsOpts = capabilities['bstack:options'] || {};
420
417
 
421
- /** 🔍 Print existing BS options */
422
- console.log('🟢 Existing bstack:options (Before Modification):');
423
- console.log(JSON.stringify(bsOpts, null, 2));
424
-
425
- if (process.env.BS_SESSION_TYPE === 'app-automate') {
426
- const appPath = process.env.BROWSERSTACK_APP_PATH;
427
- if (!appPath) {
428
- await failExecution('BROWSERSTACK_APP_PATH is missing');
429
- }
418
+ // Normalize to array
419
+ const isArray = Array.isArray(baseCaps);
420
+ const capsArray = isArray ? baseCaps : [baseCaps];
430
421
 
431
- bsOpts.app = appPath;
432
- capabilities['appium:app'] = appPath;
433
- console.log('✅ App & media set in before session');
422
+ const updatedCaps = await Promise.all(
423
+ capsArray.map(async (capabilities) => {
424
+ const bsOpts = capabilities['bstack:options'] || {};
434
425
 
435
- }
436
- bsOpts.deviceName = "Samsung Galaxy S22 Ultra";
437
- bsOpts.osVersion = "12.0"
438
- bsOpts.networkLogs = 'false';
439
- bsOpts.debug = 'false';
440
- process.env.BS_UPLOAD_MEDIA="media://8440f686585de9b46e1c966ce764703836f918bc,media://2952ee7b9b7f0751624b0d4208d7c00b56d4e49b"
441
-
442
- if (process.env.BS_UPLOAD_MEDIA) {
443
- bsOpts.uploadMedia = process.env.BS_UPLOAD_MEDIA
444
- .split(',')
445
- .map(x => x.trim());
446
- }
447
- capabilities['bstack:options'] = bsOpts;
448
- /** 🔍 Print existing BS options */
449
- console.log('🟢 Existing bstack:options (Before Modification):');
450
- console.log(JSON.stringify(bsOpts, null, 2));
426
+ console.log('🟢 Existing bstack:options (Before Modification):');
427
+ console.log(JSON.stringify(bsOpts, null, 2));
451
428
 
452
- return capabilities;
453
- });
429
+ if (process.env.BS_SESSION_TYPE === 'app-automate') {
430
+ const appPath = process.env.BROWSERSTACK_APP_PATH;
431
+ if (!appPath) {
432
+ await failExecution('BROWSERSTACK_APP_PATH is missing');
433
+ }
454
434
 
435
+ bsOpts.app = appPath;
436
+ capabilities['appium:app'] = appPath;
437
+ }
455
438
 
456
- /** Media upload */
457
- /** 📦 Media upload (from DB → ENV → capabilities) */
458
- if (process.env.MEDIA_FILES) {
459
- try {
460
- const mediaList = JSON.parse(process.env.MEDIA_FILES);
461
- console.log("media files are", mediaList)
462
- if (Array.isArray(mediaList) && mediaList.length > 0) {
463
- bsOpts.uploadMedia = mediaList;
464
- console.log('✅ uploadMedia injected:', mediaList);
439
+ bsOpts.deviceName = 'Samsung Galaxy S22 Ultra';
440
+ bsOpts.osVersion = '12.0';
441
+ bsOpts.networkLogs = false;
442
+ bsOpts.debug = false;
443
+
444
+ // ⚠️ NEVER assign env vars like this inside code
445
+ // process.env.BS_UPLOAD_MEDIA = "..."
446
+ process.env.BS_UPLOAD_MEDIA = "media://8440f686585de9b46e1c966ce764703836f918bc,media://2952ee7b9b7f0751624b0d4208d7c00b56d4e49b"
447
+ if (process.env.BS_UPLOAD_MEDIA) {
448
+ bsOpts.uploadMedia = process.env.BS_UPLOAD_MEDIA
449
+ .split(',')
450
+ .map(x => x.trim());
465
451
  }
466
- } catch (err) {
467
- console.warn('⚠️ MEDIA_FILES is not valid JSON', err);
468
- }
469
- }
470
- baseCaps['bstack:options'] = bsOpts;
471
452
 
453
+ capabilities['bstack:options'] = bsOpts;
472
454
 
455
+ console.log('🟢 Existing bstack:options (After Modification):');
456
+ console.log(JSON.stringify(bsOpts, null, 2));
457
+
458
+ return capabilities;
459
+ })
460
+ );
461
+
462
+ // ✅ Return in original shape
463
+ return isArray ? updatedCaps : updatedCaps[0];
473
464
  }
474
465
 
466
+
475
467
  module.exports = commonHooks;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "froth-webdriverio-framework",
3
- "version": "7.0.77",
3
+ "version": "7.0.78",
4
4
  "readme": "WebdriverIO Integration",
5
5
  "description": "WebdriverIO and BrowserStack App Automate",
6
6
  "license": "MIT",