@@ -22,6 +22,7 @@ const EventEmitter = require('events');
22
22
const Multimap = require ( './Multimap' ) ;
23
23
const fs = require ( 'fs' ) ;
24
24
const { SourceMapSupport} = require ( './SourceMapSupport' ) ;
25
+ const debug = require ( 'debug' ) ;
25
26
26
27
const INFINITE_TIMEOUT = 2147483647 ;
27
28
@@ -240,6 +241,7 @@ class TestPass {
240
241
} else {
241
242
// Otherwise, run the test itself if there is no scheduled termination.
242
243
this . _runningUserCallbacks . set ( workerId , test . _userCallback ) ;
244
+ this . _runner . _willStartTestBody ( test , workerId ) ;
243
245
test . error = await test . _userCallback . run ( state , test ) ;
244
246
if ( test . error )
245
247
await this . _runner . _sourceMapSupport . rewriteStackTraceWithSourceMaps ( test . error ) ;
@@ -252,6 +254,7 @@ class TestPass {
252
254
test . result = TestResult . Terminated ;
253
255
else
254
256
test . result = TestResult . Failed ;
257
+ this . _runner . _didFinishTestBody ( test , workerId ) ;
255
258
}
256
259
for ( let i = suitesStack . length - 1 ; i >= 0 ; i -- )
257
260
crashed = ( await this . _runHook ( workerId , suitesStack [ i ] , 'afterEach' , state , test ) ) || crashed ;
@@ -267,19 +270,23 @@ class TestPass {
267
270
const hook = suite [ hookName ] ;
268
271
if ( ! hook )
269
272
return false ;
273
+ this . _runner . _willStartHook ( suite , hook , hookName , workerId ) ;
270
274
this . _runningUserCallbacks . set ( workerId , hook ) ;
271
275
const error = await hook . run ( ...args ) ;
272
276
this . _runningUserCallbacks . delete ( workerId , hook ) ;
273
277
if ( error === TimeoutError ) {
274
278
const location = `${ hook . location . fileName } :${ hook . location . lineNumber } :${ hook . location . columnNumber } ` ;
275
279
const message = `${ location } - Timeout Exceeded ${ hook . timeout } ms while running "${ hookName } " in suite "${ suite . fullName } "` ;
280
+ this . _runner . _didFailHook ( suite , hook , hookName ) ;
276
281
return await this . _terminate ( TestResult . Crashed , message , null ) ;
277
282
}
278
283
if ( error ) {
279
284
const location = `${ hook . location . fileName } :${ hook . location . lineNumber } :${ hook . location . columnNumber } ` ;
280
285
const message = `${ location } - FAILED while running "${ hookName } " in suite "${ suite . fullName } "` ;
286
+ this . _runner . _didFailHook ( suite , hook , hookName ) ;
281
287
return await this . _terminate ( TestResult . Crashed , message , error ) ;
282
288
}
289
+ this . _runner . _didCompleteHook ( suite , hook , hookName ) ;
283
290
return false ;
284
291
}
285
292
@@ -289,6 +296,7 @@ class TestPass {
289
296
if ( error && error . stack )
290
297
await this . _runner . _sourceMapSupport . rewriteStackTraceWithSourceMaps ( error ) ;
291
298
this . _termination = { result, message, error} ;
299
+ this . _runner . _willTerminate ( this . _termination ) ;
292
300
for ( const userCallback of this . _runningUserCallbacks . valuesArray ( ) )
293
301
userCallback . terminate ( ) ;
294
302
return true ;
@@ -509,6 +517,30 @@ class TestRunner extends EventEmitter {
509
517
test . endTimestamp = Date . now ( ) ;
510
518
this . emit ( TestRunner . Events . TestFinished , test , workerId ) ;
511
519
}
520
+
521
+ _willStartTestBody ( test , workerId ) {
522
+ debug ( 'testrunner:test' ) ( `starting "${ test . fullName } " (${ test . location . fileName + ':' + test . location . lineNumber } )` ) ;
523
+ }
524
+
525
+ _didFinishTestBody ( test , workerId ) {
526
+ debug ( 'testrunner:test' ) ( `${ test . result . toUpperCase ( ) } "${ test . fullName } " (${ test . location . fileName + ':' + test . location . lineNumber } )` ) ;
527
+ }
528
+
529
+ _willStartHook ( suite , hook , hookName , workerId ) {
530
+ debug ( 'testrunner:hook' ) ( `"${ hookName } " started for "${ suite . fullName } " (${ hook . location . fileName + ':' + hook . location . lineNumber } )` ) ;
531
+ }
532
+
533
+ _didFailHook ( suite , hook , hookName , workerId ) {
534
+ debug ( 'testrunner:hook' ) ( `"${ hookName } " FAILED for "${ suite . fullName } " (${ hook . location . fileName + ':' + hook . location . lineNumber } )` ) ;
535
+ }
536
+
537
+ _didCompleteHook ( suite , hook , hookName , workerId ) {
538
+ debug ( 'testrunner:hook' ) ( `"${ hookName } " OK for "${ suite . fullName } " (${ hook . location . fileName + ':' + hook . location . lineNumber } )` ) ;
539
+ }
540
+
541
+ _willTerminate ( termination ) {
542
+ debug ( 'testrunner' ) ( `TERMINTED result = ${ termination . result } , message = ${ termination . message } ` ) ;
543
+ }
512
544
}
513
545
514
546
async function setLogBreakpoints ( debuggerLogBreakpoints ) {
0 commit comments