diff --git a/README.md b/README.md index 544f5b9..ef5dc33 100755 --- a/README.md +++ b/README.md @@ -80,6 +80,9 @@ string; default: null; Cypress specs root relative to package json. [More detail #### `options.outputTarget` object; default: null; Output logs to files. [More details](#logging-to-files). +#### `options.outputVerbose` +boolean; default: true; Toggles verbose output. + #### `options.printLogsToConsole` string; Default: 'onFail'. When to print logs to console, possible values: 'always', 'onFail', 'never' - When set to always logs will be printed to console for successful tests as well as failing ones. diff --git a/src/installLogsPrinter.d.ts b/src/installLogsPrinter.d.ts index a79aa8d..780b6b6 100644 --- a/src/installLogsPrinter.d.ts +++ b/src/installLogsPrinter.d.ts @@ -44,6 +44,12 @@ interface PluginOptions { | ((messages: Record>) => string) >; + /** + * Toggles verbose output. + * @default true + */ + outputVerbose?: boolean | true; + /** * Cypress specs root relative to package json. [More details](https://github.com/archfz/cypress-terminal-report#logging-to-files). * @default null diff --git a/src/installLogsPrinter.js b/src/installLogsPrinter.js index e38988a..ecb1541 100755 --- a/src/installLogsPrinter.js +++ b/src/installLogsPrinter.js @@ -107,7 +107,8 @@ function installLogsPrinter(on, options = {}) { outputProcessors.forEach((processor) => { if (Object.entries(allMessages).length !== 0){ processor.write(allMessages); - logOutputTarget(processor); + if (options.outputVerbose !== false) + logOutputTarget(processor); } }); allMessages = {}; diff --git a/src/installLogsPrinter.schema.json b/src/installLogsPrinter.schema.json index 8a67784..2275bcd 100644 --- a/src/installLogsPrinter.schema.json +++ b/src/installLogsPrinter.schema.json @@ -50,6 +50,9 @@ } } }, + "outputVerbose": { + "type": "boolean" + }, "collectTestLogs": { "type": "function" } diff --git a/test/cypress/plugins/index.js b/test/cypress/plugins/index.js index 5861c0f..cadd422 100755 --- a/test/cypress/plugins/index.js +++ b/test/cypress/plugins/index.js @@ -35,6 +35,9 @@ module.exports = (on, config) => { }, }; } + if (config.env.disableVerbose == "1"){ + options.outputVerbose = false; + } if (config.env.generateSimpleOutput == "1") { options.outputRoot = config.projectRoot + '/output/'; options.outputTarget = {'out.txt': 'txt'}; @@ -48,6 +51,7 @@ module.exports = (on, config) => { outputTarget: { any: 100 }, + outputVerbose: "false", compactLogs: false, printLogsToConsole: true, printLogsToFile: true, diff --git a/test/test.js b/test/test.js index 086f2c6..a9699bf 100755 --- a/test/test.js +++ b/test/test.js @@ -395,6 +395,7 @@ describe('cypress-terminal-report', () => { expect(stdout).to.contain(`Error: [cypress-terminal-report] Invalid plugin install options:`); expect(stdout).to.contain(`=> .outputRoot: Invalid type: number (expected string)`); expect(stdout).to.contain(`=> .outputTarget/any: Invalid type: number (expected string/function)`); + expect(stdout).to.contain(`=> .outputVerbose: Invalid type: string (expected boolean)`); expect(stdout).to.contain(`=> .compactLogs: Invalid type: boolean (expected number)`); expect(stdout).to.contain(`=> .shouldNotBeHere: Additional properties not allowed`); expect(stdout).to.contain(`=> .printLogsToFile: Invalid type: boolean (expected string)`); @@ -428,6 +429,14 @@ describe('cypress-terminal-report', () => { }); }).timeout(90000); + it('Should not verbose.', async () => { + await runTest(commandBase(['generateNestedOutput=1', 'disableVerbose=1'], ['multiple.dots.in.spec.js']), (error, stdout) => { + expect(stdout).to.not.contain(`[cypress-terminal-report] Wrote custom logs to txt.`); + expect(stdout).to.not.contain(`[cypress-terminal-report] Wrote custom logs to json.`); + expect(stdout).to.not.contain(`[cypress-terminal-report] Wrote custom logs to custom.`); + }); + }).timeout(60000); + it('Should collect test logs if support configuration added.', async () => { await runTest(commandBase(['collectTestLogsSupport=1'], ['allTypesOfLogs.spec.js']), (error, stdout, stderr) => { expect(stdout).to.contain(`Collected 17 logs for test "All types of logs."`);