diff --git a/bin/commands/runs.js b/bin/commands/runs.js index 74604378..6411afb8 100644 --- a/bin/commands/runs.js +++ b/bin/commands/runs.js @@ -84,6 +84,9 @@ module.exports = function run(args, rawArgs) { //accept the local from env variable if provided utils.setLocal(bsConfig, args); + //set network logs + utils.setNetworkLogs(bsConfig); + // set Local Mode (on-demand/ always-on) utils.setLocalMode(bsConfig, args); diff --git a/bin/helpers/utils.js b/bin/helpers/utils.js index c9247ae7..3ab06fb1 100644 --- a/bin/helpers/utils.js +++ b/bin/helpers/utils.js @@ -1045,6 +1045,15 @@ exports.getNetworkErrorMessage = (dashboard_url) => { return chalk.red(message) } +exports.setNetworkLogs = (bsConfig) => { + if(bsConfig.run_settings.networkLogs == 'true' || bsConfig.run_settings.networkLogs == true) { + bsConfig.run_settings.networkLogs = 'true' + } else { + bsConfig.run_settings.networkLogs = 'false' + } + logger.debug(`Networks logs value: ${bsConfig.run_settings.networkLogs}`); +} + exports.versionChangedMessage = (preferredVersion, actualVersion, frameworkUpgradeMessage = '') => { let message = Constants.userMessages.CYPRESS_VERSION_CHANGED.replace("", preferredVersion); message = message.replace("", actualVersion); diff --git a/test/unit/bin/commands/runs.js b/test/unit/bin/commands/runs.js index 0f093a7f..b9213c4f 100644 --- a/test/unit/bin/commands/runs.js +++ b/test/unit/bin/commands/runs.js @@ -124,6 +124,7 @@ describe("runs", () => { setRecordCapsStub = sandbox.stub().returns(undefined); setNodeVersionStub = sandbox.stub(); setBuildTagsStub = sandbox.stub(); + setNetworkLogsStub = sandbox.stub(); }); afterEach(() => { @@ -170,7 +171,8 @@ describe("runs", () => { setRecordCaps: setRecordCapsStub, setDebugMode: setDebugModeStub, setNodeVersion: setNodeVersionStub, - setBuildTags: setBuildTagsStub + setBuildTags: setBuildTagsStub, + setNetworkLogs: setNetworkLogsStub }, '../helpers/capabilityHelper': { validate: capabilityValidatorStub @@ -221,6 +223,7 @@ describe("runs", () => { sinon.assert.calledOnce(setRecordCapsStub); sinon.assert.calledOnce(setNodeVersionStub); sinon.assert.calledOnce(setBuildTagsStub); + sinon.assert.calledOnce(setNetworkLogsStub); sinon.assert.calledOnceWithExactly( sendUsageReportStub, bsConfig, @@ -284,6 +287,7 @@ describe("runs", () => { setRecordCapsStub = sandbox.stub().returns(undefined); setNodeVersionStub = sandbox.stub(); setBuildTagsStub = sandbox.stub(); + setNetworkLogsStub = sandbox.stub(); }); afterEach(() => { @@ -333,7 +337,8 @@ describe("runs", () => { setRecordCaps: setRecordCapsStub, setDebugMode: setDebugModeStub, setNodeVersion: setNodeVersionStub, - setBuildTags: setBuildTagsStub + setBuildTags: setBuildTagsStub, + setNetworkLogs: setNetworkLogsStub }, '../helpers/capabilityHelper': { validate: capabilityValidatorStub, @@ -403,6 +408,7 @@ describe("runs", () => { sinon.assert.calledOnce(setRecordCapsStub); sinon.assert.calledOnce(setNodeVersionStub); sinon.assert.calledOnce(setBuildTagsStub); + sinon.assert.calledOnce(setNetworkLogsStub); sinon.assert.calledOnceWithExactly( sendUsageReportStub, bsConfig, @@ -468,6 +474,7 @@ describe("runs", () => { setRecordCapsStub = sandbox.stub().returns(undefined); setNodeVersionStub = sandbox.stub(); setBuildTagsStub = sandbox.stub(); + setNetworkLogsStub = sandbox.stub(); }); afterEach(() => { @@ -518,7 +525,8 @@ describe("runs", () => { setRecordCaps: setRecordCapsStub, setDebugMode: setDebugModeStub, setNodeVersion: setNodeVersionStub, - setBuildTags: setBuildTagsStub + setBuildTags: setBuildTagsStub, + setNetworkLogs: setNetworkLogsStub }, '../helpers/capabilityHelper': { validate: capabilityValidatorStub, @@ -590,6 +598,7 @@ describe("runs", () => { sinon.assert.calledOnce(setRecordCapsStub); sinon.assert.calledOnce(setNodeVersionStub); sinon.assert.calledOnce(setBuildTagsStub); + sinon.assert.calledOnce(setNetworkLogsStub); sinon.assert.calledOnceWithExactly( sendUsageReportStub, bsConfig, @@ -660,6 +669,7 @@ describe("runs", () => { setRecordCapsStub = sandbox.stub().returns(undefined); setNodeVersionStub = sandbox.stub(); setBuildTagsStub = sandbox.stub(); + setNetworkLogsStub = sandbox.stub(); }); afterEach(() => { @@ -711,7 +721,8 @@ describe("runs", () => { setRecordCaps: setRecordCapsStub, setDebugMode: setDebugModeStub, setNodeVersion: setNodeVersionStub, - setBuildTags: setBuildTagsStub + setBuildTags: setBuildTagsStub, + setNetworkLogs: setNetworkLogsStub }, '../helpers/capabilityHelper': { validate: capabilityValidatorStub, @@ -793,7 +804,7 @@ describe("runs", () => { sinon.assert.calledOnce(setRecordCapsStub); sinon.assert.calledOnce(setNodeVersionStub); sinon.assert.calledOnce(setBuildTagsStub); - + sinon.assert.calledOnce(setNetworkLogsStub); sinon.assert.calledOnceWithExactly( sendUsageReportStub, bsConfig, @@ -877,6 +888,7 @@ describe("runs", () => { setRecordCapsStub = sandbox.stub().returns(undefined); setNodeVersionStub = sandbox.stub(); setBuildTagsStub = sandbox.stub(); + setNetworkLogsStub = sandbox.stub(); }); afterEach(() => { @@ -936,7 +948,8 @@ describe("runs", () => { setRecordCaps: setRecordCapsStub, setDebugMode: setDebugModeStub, setNodeVersion: setNodeVersionStub, - setBuildTags: setBuildTagsStub + setBuildTags: setBuildTagsStub, + setNetworkLogs: setNetworkLogsStub }, '../helpers/capabilityHelper': { validate: capabilityValidatorStub, @@ -1035,6 +1048,7 @@ describe("runs", () => { sinon.assert.calledOnce(setRecordCapsStub); sinon.assert.calledOnce(setNodeVersionStub); sinon.assert.calledOnce(setBuildTagsStub); + sinon.assert.calledOnce(setNetworkLogsStub); sinon.assert.match( sendUsageReportStub.getCall(0).args, [ diff --git a/test/unit/bin/helpers/utils.js b/test/unit/bin/helpers/utils.js index 4ee15936..7288c54d 100644 --- a/test/unit/bin/helpers/utils.js +++ b/test/unit/bin/helpers/utils.js @@ -3148,6 +3148,52 @@ describe('utils', () => { }); }); + describe('setNetworkLogs', () => { + it('should return true if networkLogs is passed as boolean true', () => { + let bsConfig = { + run_settings: { networkLogs: true } + }; + let expectResult = { + run_settings: { networkLogs: 'true' } + } + utils.setNetworkLogs(bsConfig); + expect(bsConfig).to.be.eql(expectResult); + }); + + it('should return true if networkLogs is passed as string true', () => { + let bsConfig = { + run_settings: { networkLogs: "true" } + }; + let expectResult = { + run_settings: { networkLogs: "true" } + } + utils.setNetworkLogs(bsConfig); + expect(bsConfig).to.be.eql(expectResult); + }); + + it('should return false if networkLogs is passed as any other non true value', () => { + let bsConfig = { + run_settings: { networkLogs: "abc" } + }; + let expectResult = { + run_settings: { networkLogs: "false" } + } + utils.setNetworkLogs(bsConfig); + expect(bsConfig).to.be.eql(expectResult); + }); + + it('should return false if networkLogs is not passed', () => { + let bsConfig = { + run_settings: { } + }; + let expectResult = { + run_settings: { networkLogs: "false" } + } + utils.setNetworkLogs(bsConfig); + expect(bsConfig).to.be.eql(expectResult); + }); + }); + describe('isSpecTimeoutArgPassed', () => { let searchForOptionStub; beforeEach(() => {