File tree 2 files changed +37
-3
lines changed
2 files changed +37
-3
lines changed Original file line number Diff line number Diff line change @@ -184,6 +184,13 @@ export default class CustomDotReporter {
184
184
)
185
185
) ;
186
186
}
187
+ if ( this . globalFailures . length ) {
188
+ this . write (
189
+ chalk . red (
190
+ `\n\n${ this . globalFailures . length } Global Failures were detected.. Complete stack traces for failures will print at the end.`
191
+ )
192
+ ) ;
193
+ }
187
194
this . write ( `\n\n` ) ;
188
195
189
196
this . reportPendingTests ( ) ;
@@ -214,7 +221,7 @@ export default class CustomDotReporter {
214
221
215
222
this . clearState ( ) ;
216
223
217
- return this . failedTests . length ? 1 : 0 ;
224
+ return this . globalFailures . length || this . failedTests . length ? 1 : 0 ;
218
225
}
219
226
220
227
addLauncher ( data ) {
Original file line number Diff line number Diff line change @@ -67,7 +67,20 @@ export async function runTest<TC extends TestContext>(
67
67
}
68
68
69
69
for ( const hook of beforeChain ) {
70
- await hook . call ( testContext , Assert ) ;
70
+ try {
71
+ await hook . call ( testContext , Assert ) ;
72
+ } catch ( err ) {
73
+ Assert . pushResult ( {
74
+ message : `Unexpected Test Failure in beforeEach: ${ ( err as Error ) . message } ` ,
75
+ stack : ( err as Error ) . stack ! ,
76
+ passed : false ,
77
+ actual : false ,
78
+ expected : true ,
79
+ } ) ;
80
+ if ( ! Config . params . tryCatch . value ) {
81
+ throw err ;
82
+ }
83
+ }
71
84
}
72
85
73
86
try {
@@ -91,7 +104,21 @@ export async function runTest<TC extends TestContext>(
91
104
}
92
105
} finally {
93
106
for ( const hook of afterChain ) {
94
- await hook . call ( testContext , Assert ) ;
107
+ try {
108
+ await hook . call ( testContext , Assert ) ;
109
+ } catch ( e ) {
110
+ Assert . pushResult ( {
111
+ message : `Unexpected Test Failure in afterEach: ${ ( e as Error ) . message } ` ,
112
+ stack : ( e as Error ) . stack ! ,
113
+ passed : false ,
114
+ actual : false ,
115
+ expected : true ,
116
+ } ) ;
117
+ if ( ! Config . params . tryCatch . value ) {
118
+ // eslint-disable-next-line no-unsafe-finally
119
+ throw e ;
120
+ }
121
+ }
95
122
}
96
123
Assert . _finalize ( ) ;
97
124
You can’t perform that action at this time.
0 commit comments