Skip to content

Commit da2fb99

Browse files
committed
Merge branch 'master' of https://github.com/browserstack/browserstack-cypress-cli into SDK-4665
2 parents 522039b + df48f6b commit da2fb99

File tree

5 files changed

+21
-8
lines changed

5 files changed

+21
-8
lines changed

bin/testObservability/cypress/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
/* Used to detect Gherkin steps */
44

5-
const util = require('util');
6-
75
let eventsQueue = [];
86
let testRunStarted = false;
97

bin/testObservability/helper/helper.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,10 @@ const getCypressCommandEventListener = (isJS) => {
284284
)
285285
}
286286

287+
const isE2ESupportFile = (file) => {
288+
return file.includes('e2e.js') || file.includes('e2e.ts');
289+
}
290+
287291
exports.setEventListeners = (bsConfig) => {
288292
try {
289293
const supportFilesData = helper.getSupportFiles(bsConfig, false);
@@ -292,7 +296,7 @@ exports.setEventListeners = (bsConfig) => {
292296
if(err) return exports.debug('EXCEPTION IN BUILD START EVENT : Unable to parse cypress support files');
293297
files.forEach(file => {
294298
try {
295-
if(!file.includes('commands.js')) {
299+
if (isE2ESupportFile(file) || !files.some(f => isE2ESupportFile(f))) {
296300
const defaultFileContent = fs.readFileSync(file, {encoding: 'utf-8'});
297301

298302
let cypressCommandEventListener = getCypressCommandEventListener(file.includes('js'));

bin/testObservability/reporter/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,16 @@ class MyReporter {
271271

272272
const port = process.env.REPORTER_API_PORT_NO;
273273

274+
this.httpServer.on('error', (error) => {
275+
if (error.code === 'EADDRINUSE') {
276+
debugOnConsole(`Port ${port} is already in use. HTTP server could not start.`);
277+
debug(`Port ${port} is already in use. HTTP server could not start.`, true, error);
278+
} else {
279+
debugOnConsole(`Exception in starting reporter server : ${error}`);
280+
debug(`Exception in starting reporter server : ${error}`, true, error);
281+
}
282+
});
283+
274284
this.httpServer.listen(port, '127.0.0.1', async () => {
275285
console.log(`Reporter HTTP server listening on port ${port}`);
276286
});

bin/testhub/utils.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const TESTHUB_CONSTANTS = require("./constants");
55
const testObservabilityHelper = require("../../bin/testObservability/helper/helper");
66
const helper = require("../helpers/helper");
77
const accessibilityHelper = require("../accessibility-automation/helper");
8-
const detect = require('detect-port');
8+
const detectPort = require('detect-port');
99

1010

1111
const isUndefined = (value) => value === undefined || value === null;
@@ -195,17 +195,18 @@ exports.logBuildError = (error, product = "") => {
195195
}
196196
};
197197

198-
exports.findAvailablePort = async (preferredPort, maxAttempts = 10) => {
198+
exports.findAvailablePort = async (preferredPort, maxAttempts = 10) => {
199+
const findPort = detectPort.detect || detectPort;
199200
let port = preferredPort;
200201
for (let attempts = 0; attempts < maxAttempts; attempts++) {
201202
try {
202-
const availablePort = await detect(port);
203+
const availablePort = await findPort(port);
203204

204205
if (availablePort === port) {
205206
return port;
206207
} else {
207208
// Double-check suggested port
208-
const verify = await detect(availablePort);
209+
const verify = await findPort(availablePort);
209210
if (verify === availablePort) {
210211
return availablePort;
211212
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "browserstack-cypress-cli",
3-
"version": "1.34.0",
3+
"version": "1.35.0",
44
"description": "BrowserStack Cypress CLI for Cypress integration with BrowserStack's remote devices.",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)