Skip to content

Commit

Permalink
#241: Ensure print logs to console on never works always.
Browse files Browse the repository at this point in the history
  • Loading branch information
archfz committed May 1, 2024
1 parent ff5f129 commit 2a5d077
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@ directory. You should add `it.only` to the test case you are working on to speed

## Release Notes

- Fix `never` on `printLogsToConsole` works in all cases. [issue](https://github.com/archfz/cypress-terminal-report/issues/241)

#### 6.0.1

- Fix `txt` output processor not logging command timings. [merge-request](https://github.com/archfz/cypress-terminal-report/pull/236) by [AlexGuironnetRTE](https://github.com/AlexGuironnetRTE)
Expand Down
8 changes: 5 additions & 3 deletions src/installLogsPrinter.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@ function installLogsPrinter(on, options = {}) {
}

if (
(options.printLogsToConsole === "onFail" && data.state !== "passed")
|| options.printLogsToConsole === "always"
|| isHookAndShouldLog
options.printLogsToConsole !== "never" && (
options.printLogsToConsole === "always"
|| (options.printLogsToConsole === "onFail" && data.state !== "passed")
|| isHookAndShouldLog
)
) {
logToTerminal(terminalMessages, options, data);
}
Expand Down
6 changes: 6 additions & 0 deletions test/specs/extendedController.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ describe('Extended controller.', () => {
});
}).timeout(60000);

it('Should not display logs from before all hooks when printing to console is never.', async function () {
await runTest(commandBase(['printSuccessfulHookLogs=1', 'enableExtendedCollector=1', 'printLogsToConsoleNever=1'], ['beforeLogs.spec.js']), (error, stdout, stderr) => {
expect(clean(stdout, true)).to.not.contain(`cy:log ${ICONS.info} some before command`);
});
}).timeout(60000);

it('Should display logs from after all hooks if they fail.', async function () {
this.retries(3);

Expand Down

0 comments on commit 2a5d077

Please sign in to comment.