Skip to content

Commit 0fe278c

Browse files
committed
build: test runner ux improvement show running timer
1 parent 9cfebe6 commit 0fe278c

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

test/BootstrapReporterView.js

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -255,35 +255,27 @@ define(function (require, exports, module) {
255255
if (reporter.activeSpecCount) {
256256
this._showProgressBar();
257257

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-
262258
// display current running test
263259
this.$info = $('<div class="alert alert-info"/>');
264260
this.$resultsContainer.append(this.$info);
265261
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);
274262
}
275263
};
276264

277265
BootstrapReporterView.prototype._handleRunnerEnd = function (event, reporter, runnerResult) {
278-
// Stop and cleanup the running timer
266+
// Stop the running timer and mark as completed
279267
if (this.runningTimer) {
280268
clearInterval(this.runningTimer);
281269
this.runningTimer = null;
270+
271+
// Show final time with completed status
272+
if (this.$timer && this.testStartTime) {
273+
const finalTime = formatElapsedTime(Date.now() - this.testStartTime);
274+
this.$timer.text('🏁 ' + finalTime + ' (Completed)');
275+
this.$timer.css('color', '#28a745'); // green color for completed
276+
}
282277
this.testStartTime = null;
283278
}
284-
if (this.$timer) {
285-
this.$timer.hide();
286-
}
287279

288280
if (this.$info) {
289281
this.$info.toggleClass("alert-info", false);
@@ -317,6 +309,19 @@ define(function (require, exports, module) {
317309
};
318310

319311
BootstrapReporterView.prototype._handleSpecStart = function (event, reporter, specName) {
312+
// Create and start timer on first spec if not already created
313+
if (!this.$timer && this.$info) {
314+
this.$timer = $('<div style="text-align: right; font-family: monospace; color: #666; margin-bottom: 5px;">⏱️ 00:00:00</div>');
315+
this.$timer.insertBefore(this.$info);
316+
317+
this.testStartTime = Date.now();
318+
this.runningTimer = setInterval(() => {
319+
if (this.$timer) {
320+
this.$timer.text('⏱️ ' + formatElapsedTime(Date.now() - this.testStartTime));
321+
}
322+
}, 1000);
323+
}
324+
320325
this.$info.text("Running " + specName);
321326
};
322327

0 commit comments

Comments
 (0)