Skip to content

Commit

Permalink
Merge pull request #236 from AlexGuironnetRTE/207_txtOutput
Browse files Browse the repository at this point in the history
#207: Add timestamp to txt output
  • Loading branch information
archfz authored Feb 24, 2024
2 parents db2305e + 2c4392e commit ad34c87
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ directory. You should add `it.only` to the test case you are working on to speed
#### 6.0.0
- Add new option [`commandTimings`](#optionscommandtimings) to display the time of the logs. [issue](https://github.com/archfz/cypress-terminal-report/issues/207)
- ! Breaking change: Refactored the log type: `[type, message, severity]` is now `{type, severity, message}`.
- ! Breaking change: Refactored the log type: `[type, message, severity]` is now `{type, message, severity}`.
- If you have used any of the following options, you will have to make changes in the integration:
`collectTestLogs`, `filterLog`, `processLog`, custom file output processor.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions src/outputProcessor/logsTxtFormatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,22 @@ const padTypeText = (text) => {
+ text;
}

const padTimeText = (text) => {
return PADDING_LOGS + text;
}

function logsTxtFormatter(logs, EOL = '\n') {
return logs.map(({type, message, severity}) => {
return (padTypeText(`${type} (${{
return logs.map(({type, message, severity, timeString}) => {
let formattedLog = (padTypeText(`${type} (${{
[CONSTANTS.SEVERITY.ERROR]: 'X',
[CONSTANTS.SEVERITY.WARNING]: '!',
[CONSTANTS.SEVERITY.SUCCESS]: 'K',
}[severity]}): `) +
message.replace(/\n/g, `${EOL}${PADDING_LOGS}`) + EOL).replace(/\s+\n/, '\n');
if (timeString) {
formattedLog = padTimeText(`Time: ${timeString}`) + `\n` + formattedLog;
}
return formattedLog;
}).join('');
}

Expand Down

0 comments on commit ad34c87

Please sign in to comment.