Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added config option outputVerbose, added test for it and README.md ex… #80

Merged
merged 2 commits into from
Mar 9, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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; Indicates whether 'Wrote custom logs to ..' appears on the console or not.
archfz marked this conversation as resolved.
Show resolved Hide resolved

#### `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.
Expand Down
6 changes: 6 additions & 0 deletions src/installLogsPrinter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ interface PluginOptions {
| ((messages: Record<string, Record<string, [string, string, Severity]>>) => string)
>;

/**
* Indicates whether 'Wrote custom logs to ..' appears on the console or not.
* @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
Expand Down
3 changes: 2 additions & 1 deletion src/installLogsPrinter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down
3 changes: 3 additions & 0 deletions src/installLogsPrinter.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
}
}
},
"outputVerbose": {
"type": "boolean"
},
"collectTestLogs": {
"type": "function"
}
Expand Down
4 changes: 4 additions & 0 deletions test/cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'};
Expand All @@ -48,6 +51,7 @@ module.exports = (on, config) => {
outputTarget: {
any: 100
},
outputVerbose: "false",
compactLogs: false,
printLogsToConsole: true,
printLogsToFile: true,
Expand Down
9 changes: 9 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)`);
Expand Down Expand Up @@ -428,6 +429,14 @@ describe('cypress-terminal-report', () => {
});
}).timeout(90000);

it('Should not verbose files printed to.', async () => {
archfz marked this conversation as resolved.
Show resolved Hide resolved
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."`);
Expand Down