browserstack-cypress-cli 1.14.1 → 1.15.0

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.
@@ -97,6 +97,9 @@ module.exports = function run(args, rawArgs) {
97
97
  // set record feature caps
98
98
  utils.setRecordCaps(bsConfig, args);
99
99
 
100
+ // set node version
101
+ utils.setNodeVersion(bsConfig, args);
102
+
100
103
  //set browsers
101
104
  await utils.setBrowsers(bsConfig, args);
102
105
 
@@ -254,6 +254,9 @@ const validate = (bsConfig, args) => {
254
254
  }
255
255
  }
256
256
 
257
+ if (!Utils.isUndefined(bsConfig.run_settings.nodeVersion) && typeof(bsConfig.run_settings.nodeVersion) === 'string' && !bsConfig.run_settings.nodeVersion.match(/^(\d+\.)?(\d+\.)?(\*|\d+)$/))
258
+ logger.warn(Constants.validationMessages.NODE_VERSION_PARSING_ERROR);
259
+
257
260
  resolve(cypressJson);
258
261
  });
259
262
  }
@@ -104,7 +104,8 @@ const validationMessages = {
104
104
  SPEC_TIMEOUT_LIMIT_ERROR: "The maximum allowed value of 'spec_timeout' is 120. Read more on https://browserstack.com/docs/automate/cypress/spec-timeout ",
105
105
  SPEC_TIMEOUT_NOT_PASSED_ERROR: "'spec_timeout' key not specified. Going ahead with 30 mins as the default spec timeout. Read more about how to specify the option in https://browserstack.com/docs/automate/cypress/spec-timeout ",
106
106
  PROJECT_ID_MISSING: "You have specified '--record' flag but you've not provided the 'projectId' in cypress.json or in browserstack.json. Your record functionality on cypress.io dashboard might not work as it needs both the key and the projectId",
107
- RECORD_KEY_MISSING: "You have specified '--record' flag but you've not provided the '--record-key' and we could not find any value in 'CYPRESS_RECORD_KEY' environment variable. Your record functionality on cypress.io dashboard might not work as it needs the key and projectId"
107
+ RECORD_KEY_MISSING: "You have specified '--record' flag but you've not provided the '--record-key' and we could not find any value in 'CYPRESS_RECORD_KEY' environment variable. Your record functionality on cypress.io dashboard might not work as it needs the key and projectId",
108
+ NODE_VERSION_PARSING_ERROR: "We weren't able to successfully parse the specified nodeVersion. We will be using the default nodeVersion to run your tests."
108
109
  };
109
110
 
110
111
  const cliMessages = {
@@ -151,7 +152,8 @@ const cliMessages = {
151
152
  SPEC_TIMEOUT: "Specify a value for a hard timeout for each spec execution in the 1-120 mins range. Read https://browserstack.com/docs/automate/cypress/spec-timeout for more details.",
152
153
  RECORD: "Pass the --record flag to record your Cypress runs on Cypress.io dashboard. Note: You also need to specify '--record-key' and '--projectId' arguments either in CLI or in browserstack.json.",
153
154
  RECORD_KEY: "You can specify the 'key' that is needed to record your runs on Cypress.io dashboard using the '--record-key' argument. Alternatively, you can also pass it on browserstack.json",
154
- PROJECT_ID: "You can pass the 'projectId' of your Cypress.io project where you want to record your runs if specifying the '--record' key. You can also specify this in your cypress.json or in your browserstack.json."
155
+ PROJECT_ID: "You can pass the 'projectId' of your Cypress.io project where you want to record your runs if specifying the '--record' key. You can also specify this in your cypress.json or in your browserstack.json.",
156
+ NODE_VERSION: "Pass the node version that you want BrowserStack to use to run your Cypress tests on."
155
157
  },
156
158
  COMMON: {
157
159
  DISABLE_USAGE_REPORTING: "Disable usage reporting",
@@ -291,4 +291,5 @@ function send(args) {
291
291
  module.exports = {
292
292
  send,
293
293
  cli_version_and_path,
294
+ get_version
294
295
  };
@@ -371,6 +371,36 @@ exports.setRecordCaps = (bsConfig, args) => {
371
371
  bsConfig.run_settings["projectId"] = this.setProjectId(bsConfig, args);
372
372
  }
373
373
 
374
+ exports.verifyNodeVersionOption = () => {
375
+ let nvOptionsSet = (this.searchForOption('-nv') || this.searchForOption('--nv'));
376
+ let nodeVersionHyphenLocationOptionsSet = (this.searchForOption('-node-version') || this.searchForOption('--node-version'));
377
+ let nodeVersionOptionsSet = (this.searchForOption('-nodeVersion') || this.searchForOption('--nodeVersion'));
378
+ return (nvOptionsSet || nodeVersionHyphenLocationOptionsSet || nodeVersionOptionsSet);
379
+ }
380
+
381
+ exports.setNodeVersion = (bsConfig, args) => {
382
+ let userProvidedNodeVersion = this.verifyNodeVersionOption();
383
+ bsConfig.run_settings.userProvidedNodeVersion = (userProvidedNodeVersion || (!this.isUndefined(bsConfig.run_settings.nodeVersion)) || (!this.isUndefined(bsConfig.run_settings.nodeversion)));
384
+
385
+ if (bsConfig.run_settings.userProvidedNodeVersion) {
386
+ if(!this.isUndefined(args.nodeVersion)) {
387
+ bsConfig.run_settings.nodeVersion = args.nodeVersion;
388
+ } else if (!this.isUndefined(bsConfig.run_settings.nodeversion)) {
389
+ bsConfig.run_settings.nodeVersion = bsConfig.run_settings.nodeversion;
390
+ }
391
+ }
392
+
393
+ if (this.isUndefined(bsConfig.run_settings.nodeVersion)) {
394
+ bsConfig.run_settings.nodeVersion = usageReporting.get_version('node') || '';
395
+ }
396
+
397
+ if (bsConfig.run_settings.nodeVersion && typeof(bsConfig.run_settings.nodeVersion) === 'string' && bsConfig.run_settings.nodeVersion.charAt(0).toLowerCase() === 'v') {
398
+ bsConfig.run_settings.nodeVersion = bsConfig.run_settings.nodeVersion.substr(1);
399
+ }
400
+
401
+ logger.debug(`Setting nodeVersion = ${bsConfig.run_settings.nodeVersion}`);
402
+ }
403
+
374
404
  // specs can be passed from bstack configuration file
375
405
  // specs can be passed via command line args as a string
376
406
  // command line args takes precedence over config
package/bin/runner.js CHANGED
@@ -265,6 +265,12 @@ var argv = yargs
265
265
  default: undefined,
266
266
  describe: Constants.cliMessages.RUN.PROJECT_ID,
267
267
  type: "string"
268
+ },
269
+ 'nv': {
270
+ alias: ['node-version', 'nodeVersion'],
271
+ default: undefined,
272
+ describe: Constants.cliMessages.RUN.NODE_VERSION,
273
+ type: "string"
268
274
  }
269
275
  })
270
276
  .help('help')
package/log/usage.log ADDED
@@ -0,0 +1,2 @@
1
+ {"level":"info","message":"Sending {\"event_type\":\"cypress_cli_stats\",\"data\":{\"bstack_json\":\"null\",\"run_settings\":\"\",\"os\":\"darwin\",\"os_version\":\"21.4.0\",\"bstack_json_found_in_pwd\":false,\"cypress_json_found_in_pwd\":false,\"cli_version\":\"1.13.0\",\"cli_path\":\"/Users/rahulnwn/.nvm/versions/node/v12.18.4/lib/node_modules\",\"npm_version\":\"6.14.6\",\"local_cypress_version\":null,\"ci_environment\":null,\"event_timestamp\":\"4/13/2022, 12:39:15 AM\",\"data\":null,\"raw_args\":[\"run\"],\"cli_args\":{\"_\":[\"run\"],\"cf\":\"browserstack.json\",\"config-file\":\"browserstack.json\",\"configFile\":\"browserstack.json\",\"ccf\":\"./cypress.json\",\"cypress-config-file\":\"./cypress.json\",\"cypressConfigFile\":\"./cypress.json\",\"disable-npm-warning\":false,\"disableNpmWarning\":false,\"sync\":true,\"async\":false,\"force-upload\":false,\"forceUpload\":false,\"headed\":false,\"no-wrap\":false,\"noWrap\":false,\"$0\":\"browserstack-cypress\"},\"message_type\":\"error\",\"error_code\":\"bstack_json_invalid_unknown\"}} to http://127.0.0.1:8000/send_event_cy_internal","timestamp":"2022-04-12T19:09:15.315Z"}
2
+ {"level":"info","message":"{\"attempts\":1,\"statusCode\":404}","timestamp":"2022-04-12T19:09:15.365Z"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browserstack-cypress-cli",
3
- "version": "1.14.1",
3
+ "version": "1.15.0",
4
4
  "description": "BrowserStack Cypress CLI for Cypress integration with BrowserStack's remote devices.",
5
5
  "main": "index.js",
6
6
  "scripts": {