@@ -241,7 +241,7 @@ if (process.env.REACT_CLASS_EQUIVALENCE_TEST) {
241
241
global . Error = ErrorProxy ;
242
242
}
243
243
244
- const expectTestToFail = async ( callback , errorMsg ) => {
244
+ const expectTestToFail = async ( callback , error ) => {
245
245
if ( callback . length > 0 ) {
246
246
throw Error (
247
247
'Gated test helpers do not support the `done` callback. Return a ' +
@@ -261,12 +261,12 @@ if (process.env.REACT_CLASS_EQUIVALENCE_TEST) {
261
261
// `afterEach` like we normally do. `afterEach` is too late because if it
262
262
// throws, we won't have captured it.
263
263
flushAllUnexpectedConsoleCalls ( ) ;
264
- } catch ( error ) {
264
+ } catch ( testError ) {
265
265
// Failed as expected
266
266
resetAllUnexpectedConsoleCalls ( ) ;
267
267
return ;
268
268
}
269
- throw Error ( errorMsg ) ;
269
+ throw error ;
270
270
} ;
271
271
272
272
const gatedErrorMessage = 'Gated test was expected to fail, but it passed.' ;
@@ -284,8 +284,10 @@ if (process.env.REACT_CLASS_EQUIVALENCE_TEST) {
284
284
if ( shouldPass ) {
285
285
test ( testName , callback ) ;
286
286
} else {
287
+ const error = new Error ( gatedErrorMessage ) ;
288
+ Error . captureStackTrace ( error , global . _test_gate ) ;
287
289
test ( `[GATED, SHOULD FAIL] ${ testName } ` , ( ) =>
288
- expectTestToFail ( callback , gatedErrorMessage ) ) ;
290
+ expectTestToFail ( callback , error ) ) ;
289
291
}
290
292
} ;
291
293
global . _test_gate_focus = ( gateFn , testName , callback ) => {
@@ -302,8 +304,10 @@ if (process.env.REACT_CLASS_EQUIVALENCE_TEST) {
302
304
if ( shouldPass ) {
303
305
test . only ( testName , callback ) ;
304
306
} else {
307
+ const error = new Error ( gatedErrorMessage ) ;
308
+ Error . captureStackTrace ( error , global . _test_gate_focus ) ;
305
309
test . only ( `[GATED, SHOULD FAIL] ${ testName } ` , ( ) =>
306
- expectTestToFail ( callback , gatedErrorMessage ) ) ;
310
+ expectTestToFail ( callback , error ) ) ;
307
311
}
308
312
} ;
309
313
0 commit comments