browserstack-cypress-cli 1.35.0 → 1.36.1

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.
@@ -10,7 +10,7 @@ const helper = require('../helpers/helper');
10
10
  const { CYPRESS_V10_AND_ABOVE_CONFIG_FILE_EXTENSIONS } = require('../helpers/constants');
11
11
  const { consoleHolder } = require("../testObservability/helper/constants");
12
12
  const supportFileContentMap = {}
13
- const HttpsProxyAgent = require('https-proxy-agent');
13
+ const { HttpsProxyAgent = require('https-proxy-agent') } = require('https-proxy-agent');
14
14
 
15
15
  exports.checkAccessibilityPlatform = (user_config) => {
16
16
  let accessibility = false;
@@ -471,8 +471,12 @@ module.exports = function run(args, rawArgs) {
471
471
  utils.sendUsageReport(bsConfig, args, `${err}\n${Constants.userMessages.LOCAL_START_FAILED}`, Constants.messageTypes.ERROR, 'local_start_failed', buildReportData, rawArgs);
472
472
  } else {
473
473
  logger.error(Constants.userMessages.ZIP_UPLOAD_FAILED);
474
- fileHelpers.deleteZip();
475
474
  utils.sendUsageReport(bsConfig, args, `${err}\n${Constants.userMessages.ZIP_UPLOAD_FAILED}`, Constants.messageTypes.ERROR, 'zip_upload_failed', buildReportData, rawArgs);
475
+ try {
476
+ fileHelpers.deleteZip();
477
+ } catch (err) {
478
+ utils.sendUsageReport(bsConfig, args, Constants.userMessages.ZIP_DELETE_FAILED, Constants.messageTypes.ERROR, 'zip_deletion_failed', buildReportData, rawArgs);
479
+ }
476
480
  try {
477
481
  fileHelpers.deletePackageArchieve();
478
482
  } catch (err) {
@@ -1,7 +1,7 @@
1
1
  const path = require('path');
2
2
  const fs = require('fs');
3
3
  const { consoleHolder } = require('../testObservability/helper/constants');
4
- const HttpsProxyAgent = require('https-proxy-agent');
4
+ const { HttpsProxyAgent = require('https-proxy-agent') } = require('https-proxy-agent');
5
5
  const { v4: uuidv4 } = require('uuid');
6
6
  const axios = require('axios'),
7
7
  logger = require('./logger').winstonLogger,
@@ -9,7 +9,7 @@ const logger = require('./logger').winstonLogger,
9
9
  config = require("./config");
10
10
 
11
11
  const { default: axios } = require('axios');
12
- const HttpsProxyAgent = require('https-proxy-agent');
12
+ const { HttpsProxyAgent = require('https-proxy-agent') } = require('https-proxy-agent');
13
13
  const FormData = require('form-data');
14
14
  const decompress = require('decompress');
15
15
  const unzipper = require("unzipper");
@@ -27,12 +27,15 @@ exports.fileExists = function (filePath, cb) {
27
27
 
28
28
  exports.deleteZip = () => {
29
29
  try {
30
+ if (!fs.existsSync(config.fileName)) {
31
+ return 0;
32
+ }
30
33
  fs.unlinkSync(config.fileName);
31
34
  logger.info(Constants.userMessages.ZIP_DELETED);
32
35
  return 0;
33
36
  } catch (err) {
34
37
  logger.info(Constants.userMessages.ZIP_DELETE_FAILED);
35
- return 1;
38
+ throw err;
36
39
  }
37
40
  };
38
41
 
@@ -18,7 +18,7 @@ const pGitconfig = promisify(gitconfig);
18
18
  const { readCypressConfigFile } = require('./readCypressConfigUtil');
19
19
  const { MAX_GIT_META_DATA_SIZE_IN_BYTES, GIT_META_DATA_TRUNCATED } = require('./constants')
20
20
  const CrashReporter = require('../testObservability/crashReporter');
21
- const HttpsProxyAgent = require('https-proxy-agent');
21
+ const { HttpsProxyAgent = require('https-proxy-agent') } = require('https-proxy-agent');
22
22
  const { TEST_REPORTING_ANALYTICS } = require("../testObservability/helper/constants");
23
23
 
24
24
  exports.debug = (text, shouldReport = false, throwable = null) => {
@@ -2,7 +2,7 @@ const fs = require('fs');
2
2
  const path = require('path');
3
3
  const axios = require('axios');
4
4
  const https = require('https');
5
- const HttpsProxyAgent = require('https-proxy-agent');
5
+ const { HttpsProxyAgent = require('https-proxy-agent') } = require('https-proxy-agent');
6
6
 
7
7
  const logger = require("../../helpers/logger").winstonLogger;
8
8
  const utils = require('../../helpers/utils');
@@ -2,8 +2,6 @@
2
2
 
3
3
  /* Used to detect Gherkin steps */
4
4
 
5
- const util = require('util');
6
-
7
5
  let eventsQueue = [];
8
6
  let testRunStarted = false;
9
7
 
@@ -9,7 +9,7 @@ const { spawn, execSync } = require('child_process');
9
9
  const glob = require('glob');
10
10
  const util = require('util');
11
11
  const axios = require('axios');
12
- const HttpsProxyAgent = require('https-proxy-agent');
12
+ const { HttpsProxyAgent = require('https-proxy-agent') } = require('https-proxy-agent');
13
13
 
14
14
  const { runOptions } = require('../../helpers/runnerArgs')
15
15
 
@@ -284,6 +284,10 @@ const getCypressCommandEventListener = (isJS) => {
284
284
  )
285
285
  }
286
286
 
287
+ const isE2ESupportFile = (file) => {
288
+ return file.includes('e2e.js') || file.includes('e2e.ts');
289
+ }
290
+
287
291
  exports.setEventListeners = (bsConfig) => {
288
292
  try {
289
293
  const supportFilesData = helper.getSupportFiles(bsConfig, false);
@@ -292,7 +296,7 @@ exports.setEventListeners = (bsConfig) => {
292
296
  if(err) return exports.debug('EXCEPTION IN BUILD START EVENT : Unable to parse cypress support files');
293
297
  files.forEach(file => {
294
298
  try {
295
- if(!file.includes('commands.js')) {
299
+ if (isE2ESupportFile(file) || !files.some(f => isE2ESupportFile(f))) {
296
300
  const defaultFileContent = fs.readFileSync(file, {encoding: 'utf-8'});
297
301
 
298
302
  let cypressCommandEventListener = getCypressCommandEventListener(file.includes('js'));
@@ -270,6 +270,16 @@ class MyReporter {
270
270
 
271
271
  const port = process.env.REPORTER_API_PORT_NO;
272
272
 
273
+ this.httpServer.on('error', (error) => {
274
+ if (error.code === 'EADDRINUSE') {
275
+ debugOnConsole(`Port ${port} is already in use. HTTP server could not start.`);
276
+ debug(`Port ${port} is already in use. HTTP server could not start.`, true, error);
277
+ } else {
278
+ debugOnConsole(`Exception in starting reporter server : ${error}`);
279
+ debug(`Exception in starting reporter server : ${error}`, true, error);
280
+ }
281
+ });
282
+
273
283
  this.httpServer.listen(port, '127.0.0.1', async () => {
274
284
  console.log(`Reporter HTTP server listening on port ${port}`);
275
285
  });
@@ -5,7 +5,7 @@ const TESTHUB_CONSTANTS = require("./constants");
5
5
  const testObservabilityHelper = require("../../bin/testObservability/helper/helper");
6
6
  const helper = require("../helpers/helper");
7
7
  const accessibilityHelper = require("../accessibility-automation/helper");
8
- const { detect } = require('detect-port');
8
+ const detectPort = require('detect-port');
9
9
 
10
10
 
11
11
  const isUndefined = (value) => value === undefined || value === null;
@@ -195,17 +195,18 @@ exports.logBuildError = (error, product = "") => {
195
195
  }
196
196
  };
197
197
 
198
- exports.findAvailablePort = async (preferredPort, maxAttempts = 10) => {
198
+ exports.findAvailablePort = async (preferredPort, maxAttempts = 10) => {
199
+ const findPort = detectPort.detect || detectPort;
199
200
  let port = preferredPort;
200
201
  for (let attempts = 0; attempts < maxAttempts; attempts++) {
201
202
  try {
202
- const availablePort = await detect(port);
203
+ const availablePort = await findPort(port);
203
204
 
204
205
  if (availablePort === port) {
205
206
  return port;
206
207
  } else {
207
208
  // Double-check suggested port
208
- const verify = await detect(availablePort);
209
+ const verify = await findPort(availablePort);
209
210
  if (verify === availablePort) {
210
211
  return availablePort;
211
212
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browserstack-cypress-cli",
3
- "version": "1.35.0",
3
+ "version": "1.36.1",
4
4
  "description": "BrowserStack Cypress CLI for Cypress integration with BrowserStack's remote devices.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -17,6 +17,7 @@
17
17
  "axios": "^1.7.7",
18
18
  "axios-retry": "^3.5.0",
19
19
  "browserstack-local": "1.5.4",
20
+ "https-proxy-agent": "^5.0.1",
20
21
  "chalk": "4.1.2",
21
22
  "cli-progress": "^3.10.0",
22
23
  "decompress": "4.2.1",