Skip to content

Commit 1f9ba34

Browse files
Merge branch 'master' of github.com:browserstack/browserstack-cypress-cli into allocate_parallels_wrt_specs
2 parents 303faa9 + 16ec8a2 commit 1f9ba34

File tree

10 files changed

+88
-81
lines changed

10 files changed

+88
-81
lines changed

bin/commands/info.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ module.exports = function info(args) {
1010
let bsConfigPath = utils.getConfigPath(args.cf);
1111

1212
return utils.validateBstackJson(bsConfigPath).then(function (bsConfig) {
13-
// setting setDefaultAuthHash to {} if not present and set via env variables or via args.
14-
utils.setDefaultAuthHash(bsConfig, args);
15-
13+
utils.setDefaults(bsConfig, args);
14+
1615
// accept the username from command line if provided
1716
utils.setUsername(bsConfig, args);
1817

bin/commands/runs.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ module.exports = function run(args) {
1717
return utils.validateBstackJson(bsConfigPath).then(function (bsConfig) {
1818
utils.setUsageReportingFlag(bsConfig, args.disableUsageReporting);
1919

20-
// setting setDefaultAuthHash to {} if not present and set via env variables or via args.
21-
utils.setDefaultAuthHash(bsConfig,args);
20+
utils.setDefaults(bsConfig, args);
2221

2322
// accept the username from command line or env variable if provided
2423
utils.setUsername(bsConfig, args);

bin/commands/stop.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ module.exports = function stop(args) {
1010
let bsConfigPath = utils.getConfigPath(args.cf);
1111

1212
return utils.validateBstackJson(bsConfigPath).then(function (bsConfig) {
13-
// setting setDefaultAuthHash to {} if not present and set via env variables or via args.
14-
utils.setDefaultAuthHash(bsConfig, args);
15-
13+
utils.setDefaults(bsConfig, args);
14+
1615
// accept the username from command line if provided
1716
utils.setUsername(bsConfig, args);
1817

bin/helpers/archiver.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const archiveSpecs = (runSettings, filePath, excludeFiles) => {
4242
let ignoreFiles = getFilesToIgnore(runSettings, excludeFiles);
4343

4444
Constants.allowedFileTypes.forEach(fileType => {
45-
archive.glob(`**/*.${fileType}`, { cwd: cypressFolderPath, matchBase: true, ignore: ignoreFiles });
45+
archive.glob(`**/*.${fileType}`, { cwd: cypressFolderPath, matchBase: true, ignore: ignoreFiles, dot:true });
4646
});
4747

4848
let packageJSON = {};

bin/helpers/constants.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ const messageTypes = {
8787
NULL: null
8888
}
8989

90-
const allowedFileTypes = ['js', 'json', 'txt', 'ts', 'feature', 'features', 'pdf', 'jpg', 'jpeg', 'png', 'zip'];
90+
const allowedFileTypes = ['js', 'json', 'txt', 'ts', 'feature', 'features', 'pdf', 'jpg', 'jpeg', 'png', 'zip', 'npmrc'];
9191

92-
const filesToIgnoreWhileUploading = ['node_modules/**', 'package-lock.json', 'package.json', 'browserstack-package.json', 'tests.zip', 'cypress.json']
92+
const filesToIgnoreWhileUploading = ['**/node_modules/**', 'node_modules/**', 'package-lock.json', 'package.json', 'browserstack-package.json', 'tests.zip', 'cypress.json']
9393

9494
const specFileTypes = ['js', 'ts', 'feature']
9595

bin/helpers/utils.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,16 @@ exports.setParallels = (bsConfig, args, numOfSpecs) => {
128128
}
129129
};
130130

131-
exports.setDefaultAuthHash = (bsConfig, args) => {
132-
if (
133-
this.isUndefined(bsConfig['auth']) &&
134-
(!this.isUndefined(args.username) ||
135-
!this.isUndefined(process.env.BROWSERSTACK_USERNAME))
136-
) {
131+
exports.setDefaults = (bsConfig, args) => {
132+
// setting setDefaultAuthHash to {} if not present and set via env variables or via args.
133+
if (this.isUndefined(bsConfig['auth']) && (!this.isUndefined(args.username) || !this.isUndefined(process.env.BROWSERSTACK_USERNAME))) {
137134
bsConfig['auth'] = {};
138135
}
136+
137+
// setting npm_dependencies to {} if not present
138+
if (bsConfig.run_settings && this.isUndefined(bsConfig.run_settings.npm_dependencies)) {
139+
bsConfig.run_settings.npm_dependencies = {}
140+
}
139141
}
140142

141143
exports.setUsername = (bsConfig, args) => {
@@ -293,8 +295,8 @@ exports.isCypressProjDirValid = (cypressProjDir, integrationFoldDir) => {
293295
integrationFolderDir = path.resolve(path.join(cypressProjDir, integrationFoldDir));
294296
}
295297
if (integrationFolderDir === cypressDir) return true;
296-
let parentTokens = cypressDir.split("/").filter((i) => i.length);
297-
let childTokens = integrationFolderDir.split("/").filter((i) => i.length);
298+
let parentTokens = cypressDir.split(path.sep).filter((i) => i.length);
299+
let childTokens = integrationFolderDir.split(path.sep).filter((i) => i.length);
298300
return parentTokens.every((t, i) => childTokens[i] === t);
299301
};
300302

test/unit/bin/commands/info.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe("buildInfo", () => {
3333
return "end";
3434
});
3535
getErrorCodeFromErrStub = sandbox.stub().returns("random-error");
36-
setDefaultAuthHashStub = sandbox.stub();
36+
setDefaultsStub = sandbox.stub();
3737
});
3838

3939
afterEach(() => {
@@ -59,7 +59,7 @@ describe("buildInfo", () => {
5959
setCypressConfigFilename: setCypressConfigFilenameStub,
6060
getUserAgent: getUserAgentStub,
6161
getConfigPath: getConfigPathStub,
62-
setDefaultAuthHash: setDefaultAuthHashStub
62+
setDefaults: setDefaultsStub
6363
},
6464
request: {get: requestStub},
6565
});
@@ -97,7 +97,7 @@ describe("buildInfo", () => {
9797
setCypressConfigFilename: setCypressConfigFilenameStub,
9898
getUserAgent: getUserAgentStub,
9999
getConfigPath: getConfigPathStub,
100-
setDefaultAuthHash: setDefaultAuthHashStub
100+
setDefaults: setDefaultsStub
101101
},
102102
request: {get: requestStub},
103103
});
@@ -131,7 +131,7 @@ describe("buildInfo", () => {
131131
return "end";
132132
});
133133
getErrorCodeFromErrStub = sandbox.stub().returns("random-error");
134-
setDefaultAuthHashStub = sandbox.stub();
134+
setDefaultsStub = sandbox.stub();
135135
});
136136

137137
afterEach(() => {
@@ -159,7 +159,7 @@ describe("buildInfo", () => {
159159
setCypressConfigFilename: setCypressConfigFilenameStub,
160160
getUserAgent: getUserAgentStub,
161161
getConfigPath: getConfigPathStub,
162-
setDefaultAuthHash: setDefaultAuthHashStub
162+
setDefaults: setDefaultsStub
163163
},
164164
request: {get: requestStub},
165165
});
@@ -203,7 +203,7 @@ describe("buildInfo", () => {
203203
setCypressConfigFilename: setCypressConfigFilenameStub,
204204
getUserAgent: getUserAgentStub,
205205
getConfigPath: getConfigPathStub,
206-
setDefaultAuthHash: setDefaultAuthHashStub
206+
setDefaults: setDefaultsStub
207207
},
208208
request: {get: requestStub},
209209
});
@@ -242,7 +242,7 @@ describe("buildInfo", () => {
242242
setCypressConfigFilename: setCypressConfigFilenameStub,
243243
getUserAgent: getUserAgentStub,
244244
getConfigPath: getConfigPathStub,
245-
setDefaultAuthHash: setDefaultAuthHashStub
245+
setDefaults: setDefaultsStub
246246
},
247247
request: {get: requestStub},
248248
});
@@ -278,7 +278,7 @@ describe("buildInfo", () => {
278278
return "end";
279279
});
280280
getErrorCodeFromErrStub = sandbox.stub().returns("random-error");
281-
setDefaultAuthHashStub = sandbox.stub();
281+
setDefaultsStub = sandbox.stub();
282282
});
283283

284284
afterEach(() => {
@@ -304,7 +304,7 @@ describe("buildInfo", () => {
304304
setCypressConfigFilename: setCypressConfigFilenameStub,
305305
getUserAgent: getUserAgentStub,
306306
getConfigPath: getConfigPathStub,
307-
setDefaultAuthHash: setDefaultAuthHashStub
307+
setDefaults: setDefaultsStub
308308
},
309309
request: {get: requestStub},
310310
});
@@ -338,7 +338,7 @@ describe("buildInfo", () => {
338338
return "end";
339339
});
340340
getErrorCodeFromErrStub = sandbox.stub().returns("random-error");
341-
setDefaultAuthHashStub = sandbox.stub();
341+
setDefaultsStub = sandbox.stub();
342342
});
343343

344344
afterEach(() => {
@@ -357,7 +357,7 @@ describe("buildInfo", () => {
357357
setUsageReportingFlag: setUsageReportingFlagStub,
358358
setCypressConfigFilename: setCypressConfigFilenameStub,
359359
getConfigPath: getConfigPathStub,
360-
setDefaultAuthHash: setDefaultAuthHashStub
360+
setDefaults: setDefaultsStub
361361
},
362362
});
363363

test/unit/bin/commands/runs.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ describe("runs", () => {
9898
setLocalStub = sandbox.stub();
9999
setLocalIdentifierStub = sandbox.stub();
100100
deleteResultsStub = sandbox.stub();
101-
setDefaultAuthHashStub = sandbox.stub();
101+
setDefaultsStub = sandbox.stub();
102102
});
103103

104104
afterEach(() => {
@@ -127,7 +127,7 @@ describe("runs", () => {
127127
setLocal: setLocalStub,
128128
setLocalIdentifier: setLocalIdentifierStub,
129129
deleteResults: deleteResultsStub,
130-
setDefaultAuthHash: setDefaultAuthHashStub
130+
setDefaults: setDefaultsStub
131131
},
132132
'../helpers/capabilityHelper': {
133133
validate: capabilityValidatorStub,
@@ -151,7 +151,7 @@ describe("runs", () => {
151151
sinon.assert.calledOnce(setLocalStub);
152152
sinon.assert.calledOnce(setLocalIdentifierStub);
153153
sinon.assert.calledOnce(deleteResultsStub);
154-
sinon.assert.calledOnce(setDefaultAuthHashStub);
154+
sinon.assert.calledOnce(setDefaultsStub);
155155
sinon.assert.calledOnceWithExactly(
156156
sendUsageReportStub,
157157
bsConfig,
@@ -188,8 +188,8 @@ describe("runs", () => {
188188
setLocalStub = sandbox.stub();
189189
setLocalIdentifierStub = sandbox.stub();
190190
deleteResultsStub = sandbox.stub();
191-
setDefaultAuthHashStub = sandbox.stub();
192191
getNumberOfSpecFilesStub = sandbox.stub().returns([]);
192+
setDefaultsStub = sandbox.stub();
193193
});
194194

195195
afterEach(() => {
@@ -218,7 +218,7 @@ describe("runs", () => {
218218
setLocal: setLocalStub,
219219
setLocalIdentifier: setLocalIdentifierStub,
220220
deleteResults: deleteResultsStub,
221-
setDefaultAuthHash: setDefaultAuthHashStub,
221+
setDefaults: setDefaultsStub,
222222
getNumberOfSpecFiles: getNumberOfSpecFilesStub
223223
},
224224
'../helpers/capabilityHelper': {
@@ -253,7 +253,7 @@ describe("runs", () => {
253253
sinon.assert.calledOnce(setUsageReportingFlagStub);
254254
sinon.assert.calledOnce(deleteZipStub);
255255
sinon.assert.calledOnce(deleteResultsStub);
256-
sinon.assert.calledOnce(setDefaultAuthHashStub);
256+
sinon.assert.calledOnce(setDefaultsStub);
257257
sinon.assert.calledOnceWithExactly(
258258
sendUsageReportStub,
259259
bsConfig,
@@ -291,8 +291,8 @@ describe("runs", () => {
291291
setLocalStub = sandbox.stub();
292292
setLocalIdentifierStub = sandbox.stub();
293293
deleteResultsStub = sandbox.stub();
294-
setDefaultAuthHashStub = sandbox.stub();
295294
getNumberOfSpecFilesStub = sandbox.stub().returns([]);
295+
setDefaultsStub = sandbox.stub();
296296
});
297297

298298
afterEach(() => {
@@ -321,8 +321,8 @@ describe("runs", () => {
321321
setLocal: setLocalStub,
322322
setLocalIdentifier: setLocalIdentifierStub,
323323
deleteResults: deleteResultsStub,
324-
setDefaultAuthHash: setDefaultAuthHashStub,
325-
getNumberOfSpecFiles: getNumberOfSpecFilesStub
324+
getNumberOfSpecFiles: getNumberOfSpecFilesStub,
325+
setDefaults: setDefaultsStub
326326
},
327327
'../helpers/capabilityHelper': {
328328
validate: capabilityValidatorStub,
@@ -360,7 +360,7 @@ describe("runs", () => {
360360
sinon.assert.calledOnce(setUsageReportingFlagStub);
361361
sinon.assert.calledOnce(zipUploadStub);
362362
sinon.assert.calledOnce(deleteResultsStub);
363-
sinon.assert.calledOnce(setDefaultAuthHashStub);
363+
sinon.assert.calledOnce(setDefaultsStub);
364364
sinon.assert.calledOnceWithExactly(
365365
sendUsageReportStub,
366366
bsConfig,
@@ -402,8 +402,8 @@ describe("runs", () => {
402402
setLocalStub = sandbox.stub();
403403
setLocalIdentifierStub = sandbox.stub();
404404
deleteResultsStub = sandbox.stub();
405-
setDefaultAuthHashStub = sandbox.stub();
406405
getNumberOfSpecFilesStub = sandbox.stub().returns([]);
406+
setDefaultsStub = sandbox.stub();
407407
});
408408

409409
afterEach(() => {
@@ -432,8 +432,8 @@ describe("runs", () => {
432432
setLocal: setLocalStub,
433433
setLocalIdentifier: setLocalIdentifierStub,
434434
deleteResults: deleteResultsStub,
435-
setDefaultAuthHash: setDefaultAuthHashStub,
436-
getNumberOfSpecFiles: getNumberOfSpecFilesStub
435+
getNumberOfSpecFiles: getNumberOfSpecFilesStub,
436+
setDefaults: setDefaultsStub
437437
},
438438
'../helpers/capabilityHelper': {
439439
validate: capabilityValidatorStub,
@@ -480,7 +480,7 @@ describe("runs", () => {
480480

481481
sinon.assert.calledOnce(sendUsageReportStub);
482482
sinon.assert.calledOnce(deleteResultsStub);
483-
sinon.assert.calledOnce(setDefaultAuthHashStub);
483+
sinon.assert.calledOnce(setDefaultsStub);
484484

485485
sinon.assert.calledOnceWithExactly(
486486
sendUsageReportStub,
@@ -524,7 +524,7 @@ describe("runs", () => {
524524
deleteZipStub = sandbox.stub();
525525
exportResultsStub = sandbox.stub();
526526
deleteResultsStub = sandbox.stub();
527-
setDefaultAuthHashStub = sandbox.stub();
527+
setDefaultsStub = sandbox.stub();
528528
isUndefinedStub = sandbox.stub();
529529
setLocalStub = sandbox.stub();
530530
setLocalIdentifierStub = sandbox.stub();
@@ -559,7 +559,7 @@ describe("runs", () => {
559559
setLocalIdentifier: setLocalIdentifierStub,
560560
exportResults: exportResultsStub,
561561
deleteResults: deleteResultsStub,
562-
setDefaultAuthHash: setDefaultAuthHashStub,
562+
setDefaults: setDefaultsStub,
563563
isUndefined: isUndefinedStub,
564564
getNumberOfSpecFiles: getNumberOfSpecFilesStub
565565
},
@@ -610,7 +610,7 @@ describe("runs", () => {
610610
sinon.assert.calledOnce(createBuildStub);
611611
sinon.assert.calledOnce(exportResultsStub);
612612
sinon.assert.calledOnce(deleteResultsStub);
613-
sinon.assert.calledOnce(setDefaultAuthHashStub);
613+
sinon.assert.calledOnce(setDefaultsStub);
614614
sinon.assert.calledOnceWithExactly(
615615
sendUsageReportStub,
616616
bsConfig,

0 commit comments

Comments
 (0)