Skip to content

Commit 3a3ceca

Browse files
Merge pull request #533 from roshan04/support_cypress_network_logs
Support cypress network logs
2 parents 23edcdb + 1059aba commit 3a3ceca

File tree

4 files changed

+78
-6
lines changed

4 files changed

+78
-6
lines changed

bin/commands/runs.js

+3
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ module.exports = function run(args, rawArgs) {
8484
//accept the local from env variable if provided
8585
utils.setLocal(bsConfig, args);
8686

87+
//set network logs
88+
utils.setNetworkLogs(bsConfig);
89+
8790
// set Local Mode (on-demand/ always-on)
8891
utils.setLocalMode(bsConfig, args);
8992

bin/helpers/utils.js

+9
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,15 @@ exports.getNetworkErrorMessage = (dashboard_url) => {
11121112
return chalk.red(message)
11131113
}
11141114

1115+
exports.setNetworkLogs = (bsConfig) => {
1116+
if(bsConfig.run_settings.networkLogs == 'true' || bsConfig.run_settings.networkLogs == true) {
1117+
bsConfig.run_settings.networkLogs = 'true'
1118+
} else {
1119+
bsConfig.run_settings.networkLogs = 'false'
1120+
}
1121+
logger.debug(`Networks logs value: ${bsConfig.run_settings.networkLogs}`);
1122+
}
1123+
11151124
exports.versionChangedMessage = (preferredVersion, actualVersion, frameworkUpgradeMessage = '') => {
11161125
let message = Constants.userMessages.CYPRESS_VERSION_CHANGED.replace("<preferredVersion>", preferredVersion);
11171126
message = message.replace("<actualVersion>", actualVersion);

test/unit/bin/commands/runs.js

+20-6
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ describe("runs", () => {
124124
setRecordCapsStub = sandbox.stub().returns(undefined);
125125
setNodeVersionStub = sandbox.stub();
126126
setBuildTagsStub = sandbox.stub();
127+
setNetworkLogsStub = sandbox.stub();
127128
});
128129

129130
afterEach(() => {
@@ -170,7 +171,8 @@ describe("runs", () => {
170171
setRecordCaps: setRecordCapsStub,
171172
setDebugMode: setDebugModeStub,
172173
setNodeVersion: setNodeVersionStub,
173-
setBuildTags: setBuildTagsStub
174+
setBuildTags: setBuildTagsStub,
175+
setNetworkLogs: setNetworkLogsStub
174176
},
175177
'../helpers/capabilityHelper': {
176178
validate: capabilityValidatorStub
@@ -220,6 +222,7 @@ describe("runs", () => {
220222
sinon.assert.calledOnce(getInitialDetailsStub);
221223
sinon.assert.calledOnce(setNodeVersionStub);
222224
sinon.assert.calledOnce(setBuildTagsStub);
225+
sinon.assert.calledOnce(setNetworkLogsStub);
223226
sinon.assert.calledOnceWithExactly(
224227
sendUsageReportStub,
225228
bsConfig,
@@ -283,6 +286,7 @@ describe("runs", () => {
283286
setRecordCapsStub = sandbox.stub().returns(undefined);
284287
setNodeVersionStub = sandbox.stub();
285288
setBuildTagsStub = sandbox.stub();
289+
setNetworkLogsStub = sandbox.stub();
286290
});
287291

288292
afterEach(() => {
@@ -332,7 +336,8 @@ describe("runs", () => {
332336
setRecordCaps: setRecordCapsStub,
333337
setDebugMode: setDebugModeStub,
334338
setNodeVersion: setNodeVersionStub,
335-
setBuildTags: setBuildTagsStub
339+
setBuildTags: setBuildTagsStub,
340+
setNetworkLogs: setNetworkLogsStub
336341
},
337342
'../helpers/capabilityHelper': {
338343
validate: capabilityValidatorStub,
@@ -402,6 +407,7 @@ describe("runs", () => {
402407
sinon.assert.calledOnce(setRecordCapsStub);
403408
sinon.assert.calledOnce(setNodeVersionStub);
404409
sinon.assert.calledOnce(setBuildTagsStub);
410+
sinon.assert.calledOnce(setNetworkLogsStub);
405411
sinon.assert.calledOnceWithExactly(
406412
sendUsageReportStub,
407413
bsConfig,
@@ -467,6 +473,7 @@ describe("runs", () => {
467473
setRecordCapsStub = sandbox.stub().returns(undefined);
468474
setNodeVersionStub = sandbox.stub();
469475
setBuildTagsStub = sandbox.stub();
476+
setNetworkLogsStub = sandbox.stub();
470477
});
471478

472479
afterEach(() => {
@@ -517,7 +524,8 @@ describe("runs", () => {
517524
setRecordCaps: setRecordCapsStub,
518525
setDebugMode: setDebugModeStub,
519526
setNodeVersion: setNodeVersionStub,
520-
setBuildTags: setBuildTagsStub
527+
setBuildTags: setBuildTagsStub,
528+
setNetworkLogs: setNetworkLogsStub
521529
},
522530
'../helpers/capabilityHelper': {
523531
validate: capabilityValidatorStub,
@@ -589,6 +597,7 @@ describe("runs", () => {
589597
sinon.assert.calledOnce(setRecordCapsStub);
590598
sinon.assert.calledOnce(setNodeVersionStub);
591599
sinon.assert.calledOnce(setBuildTagsStub);
600+
sinon.assert.calledOnce(setNetworkLogsStub);
592601
sinon.assert.calledOnceWithExactly(
593602
sendUsageReportStub,
594603
bsConfig,
@@ -659,6 +668,7 @@ describe("runs", () => {
659668
setRecordCapsStub = sandbox.stub().returns(undefined);
660669
setNodeVersionStub = sandbox.stub();
661670
setBuildTagsStub = sandbox.stub();
671+
setNetworkLogsStub = sandbox.stub();
662672
});
663673

664674
afterEach(() => {
@@ -710,7 +720,8 @@ describe("runs", () => {
710720
setRecordCaps: setRecordCapsStub,
711721
setDebugMode: setDebugModeStub,
712722
setNodeVersion: setNodeVersionStub,
713-
setBuildTags: setBuildTagsStub
723+
setBuildTags: setBuildTagsStub,
724+
setNetworkLogs: setNetworkLogsStub
714725
},
715726
'../helpers/capabilityHelper': {
716727
validate: capabilityValidatorStub,
@@ -792,7 +803,7 @@ describe("runs", () => {
792803
sinon.assert.calledOnce(setRecordCapsStub);
793804
sinon.assert.calledOnce(setNodeVersionStub);
794805
sinon.assert.calledOnce(setBuildTagsStub);
795-
806+
sinon.assert.calledOnce(setNetworkLogsStub);
796807
sinon.assert.calledOnceWithExactly(
797808
sendUsageReportStub,
798809
bsConfig,
@@ -876,6 +887,7 @@ describe("runs", () => {
876887
setRecordCapsStub = sandbox.stub().returns(undefined);
877888
setNodeVersionStub = sandbox.stub();
878889
setBuildTagsStub = sandbox.stub();
890+
setNetworkLogsStub = sandbox.stub();
879891
});
880892

881893
afterEach(() => {
@@ -935,7 +947,8 @@ describe("runs", () => {
935947
setRecordCaps: setRecordCapsStub,
936948
setDebugMode: setDebugModeStub,
937949
setNodeVersion: setNodeVersionStub,
938-
setBuildTags: setBuildTagsStub
950+
setBuildTags: setBuildTagsStub,
951+
setNetworkLogs: setNetworkLogsStub
939952
},
940953
'../helpers/capabilityHelper': {
941954
validate: capabilityValidatorStub,
@@ -1034,6 +1047,7 @@ describe("runs", () => {
10341047
sinon.assert.calledOnce(setRecordCapsStub);
10351048
sinon.assert.calledOnce(setNodeVersionStub);
10361049
sinon.assert.calledOnce(setBuildTagsStub);
1050+
sinon.assert.calledOnce(setNetworkLogsStub);
10371051
sinon.assert.match(
10381052
sendUsageReportStub.getCall(0).args,
10391053
[

test/unit/bin/helpers/utils.js

+46
Original file line numberDiff line numberDiff line change
@@ -3406,6 +3406,52 @@ describe('utils', () => {
34063406
});
34073407
});
34083408

3409+
describe('setNetworkLogs', () => {
3410+
it('should return true if networkLogs is passed as boolean true', () => {
3411+
let bsConfig = {
3412+
run_settings: { networkLogs: true }
3413+
};
3414+
let expectResult = {
3415+
run_settings: { networkLogs: 'true' }
3416+
}
3417+
utils.setNetworkLogs(bsConfig);
3418+
expect(bsConfig).to.be.eql(expectResult);
3419+
});
3420+
3421+
it('should return true if networkLogs is passed as string true', () => {
3422+
let bsConfig = {
3423+
run_settings: { networkLogs: "true" }
3424+
};
3425+
let expectResult = {
3426+
run_settings: { networkLogs: "true" }
3427+
}
3428+
utils.setNetworkLogs(bsConfig);
3429+
expect(bsConfig).to.be.eql(expectResult);
3430+
});
3431+
3432+
it('should return false if networkLogs is passed as any other non true value', () => {
3433+
let bsConfig = {
3434+
run_settings: { networkLogs: "abc" }
3435+
};
3436+
let expectResult = {
3437+
run_settings: { networkLogs: "false" }
3438+
}
3439+
utils.setNetworkLogs(bsConfig);
3440+
expect(bsConfig).to.be.eql(expectResult);
3441+
});
3442+
3443+
it('should return false if networkLogs is not passed', () => {
3444+
let bsConfig = {
3445+
run_settings: { }
3446+
};
3447+
let expectResult = {
3448+
run_settings: { networkLogs: "false" }
3449+
}
3450+
utils.setNetworkLogs(bsConfig);
3451+
expect(bsConfig).to.be.eql(expectResult);
3452+
});
3453+
});
3454+
34093455
describe('isSpecTimeoutArgPassed', () => {
34103456
let searchForOptionStub;
34113457
beforeEach(() => {

0 commit comments

Comments
 (0)