@@ -30,6 +30,24 @@ define(function (require, exports, module) {
3030
3131 var _ = require ( "thirdparty/lodash" ) ;
3232
33+ function formatMilliseconds ( ms ) {
34+ const hours = Math . floor ( ms / ( 1000 * 60 * 60 ) ) ;
35+ const minutes = Math . floor ( ( ms % ( 1000 * 60 * 60 ) ) / ( 1000 * 60 ) ) ;
36+ const seconds = Math . floor ( ( ms % ( 1000 * 60 ) ) / 1000 ) ;
37+
38+ let result = '' ;
39+
40+ if ( hours ) {
41+ result = result + `${ hours } -Hour ` ;
42+ }
43+ if ( minutes ) {
44+ result = result + `${ minutes } -Minutes ` ;
45+ }
46+ result = `${ result } ${ seconds } -Seconds` ;
47+
48+ return result . trim ( ) ;
49+ }
50+
3351 function _addPrintableContainer ( ) {
3452 var container = $ ( `
3553<div>
@@ -236,17 +254,26 @@ define(function (require, exports, module) {
236254 }
237255 } ;
238256
239- BootstrapReporterView . prototype . _handleRunnerEnd = function ( event , reporter ) {
257+ BootstrapReporterView . prototype . _handleRunnerEnd = function ( event , reporter , runnerResult ) {
240258 if ( this . $info ) {
241259 this . $info . toggleClass ( "alert-info" , false ) ;
242260
243261 window . testResults . passed = reporter . passed ;
262+
263+ // Get total time from the reporter's runInfo if available
264+ let totalTime = null ;
265+ if ( runnerResult && runnerResult . totalTime ) {
266+ totalTime = runnerResult . totalTime ;
267+ }
268+
269+ let timeText = totalTime ? ` (Done in ${ formatMilliseconds ( totalTime ) } )` : '' ;
270+
244271 if ( reporter . passed ) {
245- this . $info . toggleClass ( "alert-success" , true ) . text ( "Complete. No failures." ) ;
272+ this . $info . toggleClass ( "alert-success" , true ) . text ( "Complete. No failures." + timeText ) ;
246273 } else {
247274 this . $info . toggleClass ( "alert-error" , true ) . text (
248275 "Complete. See failures Below. If all tests have passed and no failures are seen below," +
249- "Check the debug console for errors. (search for 'Spec Error:' , 'Suite Error:' or Runner Error: in console)" ) ;
276+ "Check the debug console for errors. (search for 'Spec Error:' , 'Suite Error:' or Runner Error: in console)" + timeText ) ;
250277 }
251278 window . playWrightRunComplete = true ;
252279 }
0 commit comments