forked from akshayp7/playwright-typescript-playwright-test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustomReporterConfig.ts
36 lines (29 loc) · 1.09 KB
/
CustomReporterConfig.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { Reporter, TestCase, TestError, TestResult, TestStep } from "@playwright/test/reporter";
const winston = require(`winston`);
const console = new winston.transports.Console();
const logger = winston.createLogger({
level: 'info',
format: winston.format.json(),
transports: [
// - Write all logs with importance level of `info` or less than it
new winston.transports.File({ filename: 'logs/info.log', level: 'info' }),
],
});
// Writes logs to console
logger.add(console);
export default class CustomReporterConfig implements Reporter {
onTestBegin(test: TestCase): void {
logger.info(`Test Case Started : ${test.title}`);
}
onTestEnd(test: TestCase, result: TestResult): void {
logger.info(`Test Case Completed : ${test.title} Status : ${result.status}`);
}
onStepBegin(test: TestCase, result: TestResult, step: TestStep): void {
if (step.category === `test.step`) {
logger.info(`Executing Step : ${step.title}`);
}
}
onError(error: TestError): void {
logger.error(error.message);
}
}