File tree 1 file changed +14
-0
lines changed
Playwright-TypeScript/src/utils
1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -7,14 +7,22 @@ const TEST_SEPARATOR = "##################";
7
7
const STEP_SEPARATOR = "------------------" ;
8
8
9
9
export default class TestListener implements Reporter {
10
+ totalTests : number = 0 ;
11
+ passedTests : number = 0 ;
12
+ failedTests : number = 0 ;
13
+
10
14
onTestBegin ( test : TestCase , result : TestResult ) : void {
11
15
this . printLogs ( `Test: ${ test . title } - Started` , TEST_SEPARATOR ) ;
16
+ this . totalTests ++ ;
12
17
}
13
18
14
19
onTestEnd ( test : TestCase , result : TestResult ) : void {
15
20
if ( result . status === 'failed' ) {
21
+ this . failedTests ++ ;
16
22
const erroMessage = result . error ? result . error . stack : 'No error stack available' ;
17
23
Logger . error ( `Test: ${ test . title } - ${ result . status } \n${ erroMessage } ` ) ;
24
+ } else if ( result . status === 'passed' ) {
25
+ this . passedTests ++ ;
18
26
}
19
27
this . printLogs ( `Test: ${ test . title } - ${ result . status } ` , TEST_SEPARATOR ) ;
20
28
}
@@ -49,6 +57,12 @@ export default class TestListener implements Reporter {
49
57
Logger . error ( `Value: ${ error . value } ` ) ;
50
58
}
51
59
60
+ onEnd ( ) {
61
+ console . log ( `\nTotal Tests: ${ this . totalTests } ` ) ;
62
+ console . log ( `Passed: ${ this . passedTests } ` ) ;
63
+ console . log ( `Failed: ${ this . failedTests } ` ) ;
64
+ }
65
+
52
66
private printLogs ( msg : string , separator : string ) {
53
67
Logger . info ( separator ) ;
54
68
Logger . info ( `${ msg . toUpperCase ( ) } ` ) ;
You can’t perform that action at this time.
0 commit comments