@@ -37,7 +37,6 @@ class Reporter {
37
37
runner . on ( 'finished' , this . _onFinished . bind ( this ) ) ;
38
38
runner . on ( 'teststarted' , this . _onTestStarted . bind ( this ) ) ;
39
39
runner . on ( 'testfinished' , this . _onTestFinished . bind ( this ) ) ;
40
- this . _workersState = new Map ( ) ;
41
40
}
42
41
43
42
_onStarted ( runnableTests ) {
@@ -62,48 +61,33 @@ class Reporter {
62
61
}
63
62
}
64
63
65
- _printTermination ( result , message , error ) {
66
- console . log ( colors . red ( `## ${ result . toUpperCase ( ) } ##` ) ) ;
67
- console . log ( 'Message:' ) ;
68
- console . log ( ` ${ colors . red ( message ) } ` ) ;
69
- if ( error && error . stack ) {
70
- console . log ( 'Stack:' ) ;
71
- console . log ( padLines ( error . stack , 2 ) ) ;
64
+ _printFailedResult ( result ) {
65
+ console . log ( colors . red ( `## ${ result . result . toUpperCase ( ) } ##` ) ) ;
66
+ if ( result . message ) {
67
+ console . log ( 'Message:' ) ;
68
+ console . log ( ` ${ colors . red ( result . message ) } ` ) ;
72
69
}
73
- console . log ( 'WORKERS STATE' ) ;
74
- const workerIds = Array . from ( this . _workersState . keys ( ) ) ;
75
- workerIds . sort ( ( a , b ) => a - b ) ;
76
- for ( const workerId of workerIds ) {
77
- const { isRunning, test} = this . _workersState . get ( workerId ) ;
78
- let description = '' ;
79
- if ( isRunning )
80
- description = colors . yellow ( 'RUNNING' ) ;
81
- else if ( test . result === 'ok' )
82
- description = colors . green ( 'OK' ) ;
83
- else if ( test . result === 'skipped' )
84
- description = colors . yellow ( 'SKIPPED' ) ;
85
- else if ( test . result === 'failed' )
86
- description = colors . red ( 'FAILED' ) ;
87
- else if ( test . result === 'crashed' )
88
- description = colors . red ( 'CRASHED' ) ;
89
- else if ( test . result === 'timedout' )
90
- description = colors . red ( 'TIMEDOUT' ) ;
91
- else if ( test . result === 'terminated' )
92
- description = colors . magenta ( 'TERMINATED' ) ;
93
- else
94
- description = colors . red ( '<UNKNOWN>' ) ;
95
- console . log ( ` ${ workerId } : [${ description } ] ${ test . fullName } (${ formatLocation ( test . location ) } )` ) ;
70
+
71
+ for ( let i = 0 ; i < result . errors . length ; i ++ ) {
72
+ const { message, error, workerId, tests } = result . errors [ i ] ;
73
+ console . log ( `\n${ colors . magenta ( 'NON-TEST ERROR #' + i ) } : ${ message } ` ) ;
74
+ if ( error && error . stack )
75
+ console . log ( padLines ( error . stack , 2 ) ) ;
76
+ const lastTests = tests . slice ( tests . length - Math . min ( 10 , tests . length ) ) ;
77
+ if ( lastTests . length )
78
+ console . log ( `WORKER STATE` ) ;
79
+ for ( let j = 0 ; j < lastTests . length ; j ++ )
80
+ this . _printVerboseTestResult ( j , lastTests [ j ] , workerId ) ;
96
81
}
97
82
console . log ( '' ) ;
98
83
console . log ( '' ) ;
99
- process . exitCode = 2 ;
100
84
}
101
85
102
- _onFinished ( { result, terminationError , terminationMessage } ) {
86
+ _onFinished ( result ) {
103
87
this . _printTestResults ( ) ;
104
- if ( terminationMessage || terminationError )
105
- this . _printTermination ( result , terminationMessage , terminationError ) ;
106
- process . exitCode = result === 'ok' ? 0 : 1 ;
88
+ if ( ! result . ok ( ) )
89
+ this . _printFailedResult ( result ) ;
90
+ process . exitCode = result . exitCode ;
107
91
}
108
92
109
93
_printTestResults ( ) {
@@ -171,11 +155,9 @@ class Reporter {
171
155
}
172
156
173
157
_onTestStarted ( test , workerId ) {
174
- this . _workersState . set ( workerId , { test, isRunning : true } ) ;
175
158
}
176
159
177
160
_onTestFinished ( test , workerId ) {
178
- this . _workersState . set ( workerId , { test, isRunning : false } ) ;
179
161
if ( this . _verbose ) {
180
162
++ this . _testCounter ;
181
163
this . _printVerboseTestResult ( this . _testCounter , test , workerId ) ;
@@ -240,7 +222,11 @@ class Reporter {
240
222
console . log ( '' ) ;
241
223
} else {
242
224
console . log ( ' Message:' ) ;
243
- console . log ( ` ${ colors . red ( test . error . message || test . error ) } ` ) ;
225
+ let message = '' + ( test . error . message || test . error ) ;
226
+ if ( test . error . stack && message . includes ( test . error . stack ) )
227
+ message = message . substring ( 0 , message . indexOf ( test . error . stack ) ) ;
228
+ if ( message )
229
+ console . log ( ` ${ colors . red ( message ) } ` ) ;
244
230
if ( test . error . stack ) {
245
231
console . log ( ' Stack:' ) ;
246
232
let stack = test . error . stack ;
0 commit comments