Skip to content

Added qavajs/console-formatter and winston logger for better results and debugging. #10

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

Merged
merged 5 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 6 additions & 2 deletions config/cucumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
theme: {
...DEFAULT_THEME,
'step status': ['red'],
'step text': ['white'],
'step text': ['green'],
'feature description': ['white', 'italic'],
'feature keyword': ['cyan', 'bold'],
'feature name': ['white', 'underline'],
Expand All @@ -19,6 +19,10 @@ module.exports = {
'step keyword': ['green'],
'step status': ['bold', 'red'],
},
console: {
showLogs: true,
showProgress: false
}
},
compilerOptions: {
esModuleInterop: true,
Expand All @@ -38,7 +42,7 @@ module.exports = {
format: [
"html:test-results/reports/cucumber-report.html",
"json:test-results/reports/cucumber-report.json",
"@cucumber/pretty-formatter"
"@qavajs/console-formatter"
],
},
};
40 changes: 40 additions & 0 deletions logger/logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { createLogger, format, transports } from 'winston';
import { allColors } from 'winston/lib/winston/config';

const { combine, timestamp, printf, colorize } = format;

const createCustomLogger = (scenarioName: string) => {
const customFormat = printf(({ timestamp, level, message }) => {
return ` [${timestamp}] ${level} ${message}`;
});

return createLogger({
level: 'info',
format: combine(
timestamp(
{
format: 'DD-M-YY HH:mm:ss',
}
),
colorize(allColors),
customFormat
),
transports: [
new transports.Console(),
new transports.File({
filename: `test-results/logs/${scenarioName}/log.log`,
level: 'info',
format: format.combine(
timestamp({
format: ' DD-M-YY HH:mm:ss'
}),
format.align(),
customFormat
),
}),
],
});

};

export default createCustomLogger;
Loading
Loading