Skip to content

Commit e52f86e

Browse files
committed
Playwright TypeScript Framework
1 parent ebd6c7e commit e52f86e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Diff for: Playwright-TypeScript/src/utils/test_listener.ts

+14
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,22 @@ const TEST_SEPARATOR = "##################";
77
const STEP_SEPARATOR = "------------------";
88

99
export default class TestListener implements Reporter {
10+
totalTests: number = 0;
11+
passedTests: number = 0;
12+
failedTests: number = 0;
13+
1014
onTestBegin(test: TestCase, result: TestResult): void {
1115
this.printLogs(`Test: ${test.title} - Started`, TEST_SEPARATOR);
16+
this.totalTests++;
1217
}
1318

1419
onTestEnd(test: TestCase, result: TestResult): void {
1520
if (result.status === 'failed') {
21+
this.failedTests++;
1622
const erroMessage = result.error ? result.error.stack : 'No error stack available';
1723
Logger.error(`Test: ${test.title} - ${result.status}\n${erroMessage}`);
24+
}else if (result.status === 'passed') {
25+
this.passedTests++;
1826
}
1927
this.printLogs(`Test: ${test.title} - ${result.status}`, TEST_SEPARATOR);
2028
}
@@ -49,6 +57,12 @@ export default class TestListener implements Reporter {
4957
Logger.error(`Value: ${error.value}`);
5058
}
5159

60+
onEnd() {
61+
console.log(`\nTotal Tests: ${this.totalTests}`);
62+
console.log(`Passed: ${this.passedTests}`);
63+
console.log(`Failed: ${this.failedTests}`);
64+
}
65+
5266
private printLogs(msg: string, separator: string) {
5367
Logger.info(separator);
5468
Logger.info(`${msg.toUpperCase()}`);

0 commit comments

Comments
 (0)