browserstack-cypress-cli 1.36.16 → 1.36.18

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.
@@ -491,11 +491,24 @@ exports.setNodeVersion = (bsConfig, args) => {
491
491
  }
492
492
 
493
493
  // specs can be passed from bstack configuration file
494
+ // True when the spec list for this run comes from BROWSERSTACK_RERUN_TESTS rather than
495
+ // the user's config/CLI args. Shared by setUserSpecs and getNumberOfSpecFiles so the two
496
+ // cannot drift apart — getNumberOfSpecFiles rewrites specs only for runs setUserSpecs
497
+ // actually sourced from the re-run env.
498
+ exports.isReRunSpecsSession = () => {
499
+ return o11yHelpers.isBrowserstackInfra()
500
+ && o11yHelpers.isTestObservabilitySession()
501
+ && o11yHelpers.shouldReRunObservabilityTests();
502
+ }
503
+
494
504
  // specs can be passed via command line args as a string
495
505
  // command line args takes precedence over config
496
506
  exports.setUserSpecs = (bsConfig, args) => {
497
- if(o11yHelpers.isBrowserstackInfra() && o11yHelpers.isTestObservabilitySession() && o11yHelpers.shouldReRunObservabilityTests()) {
498
- bsConfig.run_settings.specs = process.env.BROWSERSTACK_RERUN_TESTS;
507
+ if(this.isReRunSpecsSession()) {
508
+ // BROWSERSTACK_RERUN_TESTS arrives comma+space separated (e.g. "a.ts, b.ts"); normalise
509
+ // like the other spec sources below, else sanitizeSpecsPattern builds "{a.ts, b.ts}" whose
510
+ // space-prefixed brace alternatives never match and the failed-spec filter collapses.
511
+ bsConfig.run_settings.specs = this.fixCommaSeparatedString(process.env.BROWSERSTACK_RERUN_TESTS);
499
512
  return;
500
513
  }
501
514
 
@@ -1229,6 +1242,16 @@ exports.getNumberOfSpecFiles = (bsConfig, args, cypressConfig, turboScaleSession
1229
1242
  files = files.map((x) => { return x.replaceAll("\\", "/") })
1230
1243
  // setting specs for turboScale as we don't have patched API for turboscale so we will rely on info from CLI
1231
1244
  bsConfig.run_settings.specs = files;
1245
+ } else if (this.isReRunSpecsSession() && files.length) {
1246
+ // BROWSERSTACK_RERUN_TESTS arrives as bare filenames ("a.ts,b.ts"). run_settings is
1247
+ // forwarded to the remote machines verbatim, and a bare filename does not resolve
1248
+ // against the project root there, so Cypress exits having run no spec at all. The
1249
+ // glob above already resolved them against cypressProjectDir — persist those
1250
+ // project-relative paths so the remote receives something it can resolve.
1251
+ bsConfig.run_settings.specs = files
1252
+ .map((file) => path.relative(bsConfig.run_settings.cypressProjectDir, file).replaceAll("\\", "/"))
1253
+ .join(",");
1254
+ logger.debug(`Re-run specs resolved to project-relative paths: ${bsConfig.run_settings.specs}`);
1232
1255
  }
1233
1256
  return files;
1234
1257
  } catch (err) {
@@ -881,7 +881,10 @@ const getReRunSpecs = (rawArgs) => {
881
881
  }
882
882
  }
883
883
  if(startIdx != -1) rawArgs.splice(startIdx, numEle + 1);
884
- finalArgs = [...rawArgs, '--spec', process.env.BROWSERSTACK_RERUN_TESTS];
884
+ // Normalise the comma+space separated rerun list ("a.ts, b.ts") to comma-only before
885
+ // handing it to cypress --spec; a leading space makes cypress miss every spec but the first.
886
+ const reRunSpecs = process.env.BROWSERSTACK_RERUN_TESTS.split(",").map(spec => spec.trim()).filter(Boolean).join(",");
887
+ finalArgs = [...rawArgs, '--spec', reRunSpecs];
885
888
  }
886
889
  return finalArgs.filter(item => item !== '--disable-test-observability' && item !== '--disable-browserstack-automation');
887
890
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browserstack-cypress-cli",
3
- "version": "1.36.16",
3
+ "version": "1.36.18",
4
4
  "description": "BrowserStack Cypress CLI for Cypress integration with BrowserStack's remote devices.",
5
5
  "main": "index.js",
6
6
  "scripts": {