Skip to content

Commit 4620a0f

Browse files
Fixing unit test cases for env vars
1 parent 08f5190 commit 4620a0f

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

test/unit/bin/commands/runs.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ describe("runs", () => {
9191
setCypressConfigFilenameStub = sandbox.stub();
9292
setUserSpecsStub = sandbox.stub();
9393
setTestEnvsStub = sandbox.stub();
94+
setSystemEnvsStub = sandbox.stub();
9495
getConfigPathStub = sandbox.stub();
9596
setupLocalTestingStub = sandbox.stub();
9697
setUsageReportingFlagStub = sandbox.stub().returns(undefined);
@@ -141,7 +142,8 @@ describe("runs", () => {
141142
setupLocalTesting: setupLocalTestingStub,
142143
isJSONInvalid: isJSONInvalidStub,
143144
setLocalMode: setLocalModeStub,
144-
setLocalConfigFile: setLocalConfigFileStub
145+
setLocalConfigFile: setLocalConfigFileStub,
146+
setSystemEnvs: setSystemEnvsStub
145147
},
146148
'../helpers/capabilityHelper': {
147149
validate: capabilityValidatorStub
@@ -168,6 +170,7 @@ describe("runs", () => {
168170
sinon.assert.calledOnce(setCypressConfigFilenameStub);
169171
sinon.assert.calledOnce(setUserSpecsStub);
170172
sinon.assert.calledOnce(setTestEnvsStub);
173+
sinon.assert.calledOnce(setSystemEnvsStub);
171174
sinon.assert.calledOnce(setLocalStub);
172175
sinon.assert.calledOnce(setLocalModeStub);
173176
sinon.assert.calledOnce(setLocalConfigFileStub);
@@ -203,6 +206,7 @@ describe("runs", () => {
203206
setCypressConfigFilenameStub = sandbox.stub();
204207
setUserSpecsStub = sandbox.stub();
205208
setTestEnvsStub = sandbox.stub();
209+
setSystemEnvsStub = sandbox.stub();
206210
validateBstackJsonStub = sandbox.stub();
207211
setUsageReportingFlagStub = sandbox.stub().returns(undefined);
208212
sendUsageReportStub = sandbox.stub().callsFake(function () {
@@ -256,7 +260,8 @@ describe("runs", () => {
256260
deleteResults: deleteResultsStub,
257261
setDefaults: setDefaultsStub,
258262
getNumberOfSpecFiles: getNumberOfSpecFilesStub,
259-
setLocalConfigFile: setLocalConfigFileStub
263+
setLocalConfigFile: setLocalConfigFileStub,
264+
setSystemEnvs: setSystemEnvsStub
260265
},
261266
'../helpers/capabilityHelper': {
262267
validate: capabilityValidatorStub,
@@ -301,6 +306,7 @@ describe("runs", () => {
301306
sinon.assert.calledOnce(deleteZipStub);
302307
sinon.assert.calledOnce(deleteResultsStub);
303308
sinon.assert.calledOnce(setDefaultsStub);
309+
sinon.assert.calledOnce(setSystemEnvsStub);
304310
sinon.assert.calledOnceWithExactly(
305311
sendUsageReportStub,
306312
bsConfig,
@@ -327,6 +333,7 @@ describe("runs", () => {
327333
setCypressConfigFilenameStub = sandbox.stub();
328334
setUserSpecsStub = sandbox.stub();
329335
setTestEnvsStub = sandbox.stub();
336+
setSystemEnvsStub = sandbox.stub();
330337
getConfigPathStub = sandbox.stub();
331338
setUsageReportingFlagStub = sandbox.stub().returns(undefined);
332339
sendUsageReportStub = sandbox.stub().callsFake(function () {
@@ -370,6 +377,7 @@ describe("runs", () => {
370377
setCypressConfigFilename: setCypressConfigFilenameStub,
371378
setUserSpecs: setUserSpecsStub,
372379
setTestEnvs: setTestEnvsStub,
380+
setSystemEnvs: setSystemEnvsStub,
373381
setUsageReportingFlag: setUsageReportingFlagStub,
374382
getConfigPath: getConfigPathStub,
375383
setLocal: setLocalStub,
@@ -426,6 +434,7 @@ describe("runs", () => {
426434
sinon.assert.calledOnce(zipUploadStub);
427435
sinon.assert.calledOnce(deleteResultsStub);
428436
sinon.assert.calledOnce(setDefaultsStub);
437+
sinon.assert.calledOnce(setSystemEnvsStub);
429438
sinon.assert.calledOnceWithExactly(
430439
sendUsageReportStub,
431440
bsConfig,
@@ -455,6 +464,7 @@ describe("runs", () => {
455464
setCypressConfigFilenameStub = sandbox.stub();
456465
setUserSpecsStub = sandbox.stub();
457466
setTestEnvsStub = sandbox.stub();
467+
setSystemEnvsStub = sandbox.stub();
458468
getConfigPathStub = sandbox.stub();
459469
setUsageReportingFlagStub = sandbox.stub().returns(undefined);
460470
sendUsageReportStub = sandbox.stub().callsFake(function () {
@@ -500,6 +510,7 @@ describe("runs", () => {
500510
setCypressConfigFilename: setCypressConfigFilenameStub,
501511
setUserSpecs: setUserSpecsStub,
502512
setTestEnvs: setTestEnvsStub,
513+
setSystemEnvs: setSystemEnvsStub,
503514
setUsageReportingFlag: setUsageReportingFlagStub,
504515
getConfigPath: getConfigPathStub,
505516
setLocal: setLocalStub,
@@ -568,6 +579,7 @@ describe("runs", () => {
568579
sinon.assert.calledOnce(sendUsageReportStub);
569580
sinon.assert.calledOnce(deleteResultsStub);
570581
sinon.assert.calledOnce(setDefaultsStub);
582+
sinon.assert.calledOnce(setSystemEnvsStub);
571583

572584
sinon.assert.calledOnceWithExactly(
573585
sendUsageReportStub,
@@ -596,6 +608,7 @@ describe("runs", () => {
596608
setCypressConfigFilenameStub = sandbox.stub();
597609
setUserSpecsStub = sandbox.stub();
598610
setTestEnvsStub = sandbox.stub();
611+
setSystemEnvsStub = sandbox.stub();
599612
getConfigPathStub = sandbox.stub();
600613
setUsageReportingFlagStub = sandbox.stub().returns(undefined);
601614
sendUsageReportStub = sandbox.stub().callsFake(function () {
@@ -647,6 +660,7 @@ describe("runs", () => {
647660
setCypressConfigFilename: setCypressConfigFilenameStub,
648661
setUserSpecs: setUserSpecsStub,
649662
setTestEnvs: setTestEnvsStub,
663+
setSystemEnvs: setSystemEnvsStub,
650664
setUsageReportingFlag: setUsageReportingFlagStub,
651665
setParallels: setParallelsStub,
652666
warnSpecLimit: warnSpecLimitStub,
@@ -725,6 +739,7 @@ describe("runs", () => {
725739
sinon.assert.calledOnce(exportResultsStub);
726740
sinon.assert.calledOnce(deleteResultsStub);
727741
sinon.assert.calledOnce(setDefaultsStub);
742+
sinon.assert.calledOnce(setSystemEnvsStub);
728743
sinon.assert.match(
729744
sendUsageReportStub.getCall(0).args,
730745
[

test/unit/bin/helpers/capabilityHelper.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ describe("capabilityHelper.js", () => {
6969
return capabilityHelper
7070
.caps(bsConfig, { zip_url: zip_url })
7171
.then(function (data) {
72-
chai.assert.equal(JSON.parse(data).cypress_version, cypress_version);
72+
chai.assert.equal(JSON.parse(JSON.parse(data).run_settings).cypress_version, cypress_version);
7373
})
7474
.catch((error) => {
7575
chai.assert.fail("Promise error");
@@ -309,7 +309,7 @@ describe("capabilityHelper.js", () => {
309309
return capabilityHelper
310310
.caps(bsConfig, { zip_url: zip_url })
311311
.then(function (data) {
312-
let parsed_data = JSON.parse(data);
312+
let parsed_data = JSON.parse(JSON.parse(data).run_settings);
313313
chai.assert.equal(parsed_data.specs, specsList);
314314
chai.assert.equal(parsed_data.env, undefined);
315315
})
@@ -341,7 +341,7 @@ describe("capabilityHelper.js", () => {
341341
return capabilityHelper
342342
.caps(bsConfig, { zip_url: zip_url })
343343
.then(function (data) {
344-
let parsed_data = JSON.parse(data);
344+
let parsed_data = JSON.parse(JSON.parse(data).run_settings);
345345
chai.assert.equal(parsed_data.env, envList);
346346
chai.assert.equal(parsed_data.specs, undefined);
347347
})
@@ -375,7 +375,7 @@ describe("capabilityHelper.js", () => {
375375
return capabilityHelper
376376
.caps(bsConfig, { zip_url: zip_url })
377377
.then(function (data) {
378-
let parsed_data = JSON.parse(data);
378+
let parsed_data = JSON.parse(JSON.parse(data).run_settings);
379379
chai.assert.equal(parsed_data.specs, specsList);
380380
chai.assert.equal(parsed_data.env, envList);
381381
})
@@ -405,7 +405,7 @@ describe("capabilityHelper.js", () => {
405405
return capabilityHelper
406406
.caps(bsConfig, { zip_url: zip_url })
407407
.then(function (data) {
408-
let parsed_data = JSON.parse(data);
408+
let parsed_data = JSON.parse(JSON.parse(data).run_settings);
409409
chai.assert.equal(parsed_data.specs, undefined);
410410
chai.assert.equal(parsed_data.env, undefined);
411411
})
@@ -439,7 +439,7 @@ describe("capabilityHelper.js", () => {
439439
return capabilityHelper
440440
.caps(bsConfig, { zip_url: zip_url })
441441
.then(function (data) {
442-
let parsed_data = JSON.parse(data);
442+
let parsed_data = JSON.parse(JSON.parse(data).run_settings);
443443
chai.assert.equal(parsed_data.headless, headless);
444444
chai.assert.equal(parsed_data.env, undefined);
445445
})
@@ -471,7 +471,7 @@ describe("capabilityHelper.js", () => {
471471
return capabilityHelper
472472
.caps(bsConfig, { zip_url: zip_url })
473473
.then(function (data) {
474-
let parsed_data = JSON.parse(data);
474+
let parsed_data = JSON.parse(JSON.parse(data).run_settings);
475475
chai.assert.equal(parsed_data.headless, headless);
476476
chai.assert.equal(parsed_data.env, undefined);
477477
})

0 commit comments

Comments
 (0)