@@ -48,6 +48,14 @@ define(function (require, exports, module) {
4848 return result . trim ( ) ;
4949 }
5050
51+ function formatElapsedTime ( ms ) {
52+ const totalSeconds = Math . floor ( ms / 1000 ) ;
53+ const hours = Math . floor ( totalSeconds / 3600 ) ;
54+ const minutes = Math . floor ( ( totalSeconds % 3600 ) / 60 ) ;
55+ const seconds = totalSeconds % 60 ;
56+ return `${ hours . toString ( ) . padStart ( 2 , '0' ) } :${ minutes . toString ( ) . padStart ( 2 , '0' ) } :${ seconds . toString ( ) . padStart ( 2 , '0' ) } ` ;
57+ }
58+
5159 function _addPrintableContainer ( ) {
5260 var container = $ ( `
5361<div>
@@ -247,14 +255,36 @@ define(function (require, exports, module) {
247255 if ( reporter . activeSpecCount ) {
248256 this . _showProgressBar ( ) ;
249257
258+ // display running timer
259+ this . $timer = $ ( '<div style="text-align: right; font-family: monospace; color: #666; margin-bottom: 5px;">⏱️ 00:00:00</div>' ) ;
260+ this . $resultsContainer . append ( this . $timer ) ;
261+
250262 // display current running test
251263 this . $info = $ ( '<div class="alert alert-info"/>' ) ;
252264 this . $resultsContainer . append ( this . $info ) ;
253265 this . $resultsContainer . append ( $ ( '<hr/>' ) ) ;
266+
267+ // start the running timer
268+ this . testStartTime = Date . now ( ) ;
269+ this . runningTimer = setInterval ( ( ) => {
270+ if ( this . $timer ) {
271+ this . $timer . text ( '⏱️ ' + formatElapsedTime ( Date . now ( ) - this . testStartTime ) ) ;
272+ }
273+ } , 1000 ) ;
254274 }
255275 } ;
256276
257277 BootstrapReporterView . prototype . _handleRunnerEnd = function ( event , reporter , runnerResult ) {
278+ // Stop and cleanup the running timer
279+ if ( this . runningTimer ) {
280+ clearInterval ( this . runningTimer ) ;
281+ this . runningTimer = null ;
282+ this . testStartTime = null ;
283+ }
284+ if ( this . $timer ) {
285+ this . $timer . hide ( ) ;
286+ }
287+
258288 if ( this . $info ) {
259289 this . $info . toggleClass ( "alert-info" , false ) ;
260290
0 commit comments