16
16
17
17
import { ms as milliseconds } from 'playwright-core/lib/utilsBundle' ;
18
18
import path from 'path' ;
19
- import { BaseReporter , colors , formatError , formatResultFailure , formatRetry , formatTestHeader , formatTestTitle , stripAnsiEscapes } from './base' ;
19
+ import { TerminalReporter , formatResultFailure , formatRetry , noColors , stripAnsiEscapes } from './base' ;
20
20
import type { TestCase , FullResult , TestError } from '../../types/testReporter' ;
21
21
22
22
type GitHubLogType = 'debug' | 'notice' | 'warning' | 'error' ;
@@ -56,9 +56,14 @@ class GitHubLogger {
56
56
}
57
57
}
58
58
59
- export class GitHubReporter extends BaseReporter {
59
+ export class GitHubReporter extends TerminalReporter {
60
60
githubLogger = new GitHubLogger ( ) ;
61
61
62
+ constructor ( options : { omitFailures ?: boolean } = { } ) {
63
+ super ( options ) ;
64
+ this . screen . colors = noColors ;
65
+ }
66
+
62
67
printsToStdio ( ) {
63
68
return false ;
64
69
}
@@ -69,7 +74,7 @@ export class GitHubReporter extends BaseReporter {
69
74
}
70
75
71
76
override onError ( error : TestError ) {
72
- const errorMessage = formatError ( error , false ) . message ;
77
+ const errorMessage = this . formatError ( error ) . message ;
73
78
this . githubLogger . error ( errorMessage ) ;
74
79
}
75
80
@@ -100,10 +105,10 @@ export class GitHubReporter extends BaseReporter {
100
105
101
106
private _printFailureAnnotations ( failures : TestCase [ ] ) {
102
107
failures . forEach ( ( test , index ) => {
103
- const title = formatTestTitle ( this . config , test ) ;
104
- const header = formatTestHeader ( this . config , test , { indent : ' ' , index : index + 1 , mode : 'error' } ) ;
108
+ const title = this . formatTestTitle ( test ) ;
109
+ const header = this . formatTestHeader ( test , { indent : ' ' , index : index + 1 , mode : 'error' } ) ;
105
110
for ( const result of test . results ) {
106
- const errors = formatResultFailure ( test , result , ' ' , colors . enabled ) ;
111
+ const errors = formatResultFailure ( this . screen , test , result , ' ' ) ;
107
112
for ( const error of errors ) {
108
113
const options : GitHubLogOptions = {
109
114
file : workspaceRelativePath ( error . location ?. file || test . location . file ) ,
@@ -113,7 +118,7 @@ export class GitHubReporter extends BaseReporter {
113
118
options . line = error . location . line ;
114
119
options . col = error . location . column ;
115
120
}
116
- const message = [ header , ...formatRetry ( result ) , error . message ] . join ( '\n' ) ;
121
+ const message = [ header , ...formatRetry ( this . screen , result ) , error . message ] . join ( '\n' ) ;
117
122
this . githubLogger . error ( message , options ) ;
118
123
}
119
124
}
0 commit comments