Skip to content

Commit cc1fdb6

Browse files
jerrypopsoffstefanpenner
authored andcommitted
Display progress and runtime while test suite is executing (#1398)
Closes #1394
1 parent 837af39 commit cc1fdb6

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

reporter/html.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import QUnit from "../src/core";
2+
import Test from "../src/test";
23
import { extractStacktrace } from "../src/core/stacktrace";
4+
import { now } from "../src/core/utilities";
35
import { window, navigator } from "../src/globals";
46
import "./urlparams";
57

@@ -735,6 +737,29 @@ export function escapeText( s ) {
735737
return nameHtml;
736738
}
737739

740+
function getProgressHtml( runtime, stats, total ) {
741+
var completed = stats.passedTests +
742+
stats.skippedTests +
743+
stats.todoTests +
744+
stats.failedTests;
745+
746+
return [
747+
"<br />",
748+
completed,
749+
" / ",
750+
total,
751+
" tests completed in ",
752+
runtime,
753+
" milliseconds, with ",
754+
stats.failedTests,
755+
" failed, ",
756+
stats.skippedTests,
757+
" skipped, and ",
758+
stats.todoTests,
759+
" todo."
760+
].join( "" );
761+
}
762+
738763
QUnit.testStart( function( details ) {
739764
var running, bad;
740765

@@ -751,7 +776,8 @@ export function escapeText( s ) {
751776
bad ?
752777
"Rerunning previously failed test: <br />" :
753778
"Running: <br />",
754-
getNameHtml( details.name, details.module )
779+
getNameHtml( details.name, details.module ),
780+
getProgressHtml( now() - config.started, stats, Test.count )
755781
].join( "" );
756782
}
757783

test/reporter-html/reporter-html.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ QUnit.test( "running test name displayed", function( assert ) {
5050
);
5151
} );
5252

53+
QUnit.test( "running test suite progress displayed", function( assert ) {
54+
assert.expect( 1 );
55+
56+
var displaying = document.getElementById( "qunit-testresult" );
57+
58+
var expected = /\d+ \/ \d+ tests completed in \d+ milliseconds, with \d+ failed, \d+ skipped, and \d+ todo./;
59+
assert.ok(
60+
expected.test( displaying.innerHTML ),
61+
"Expect test suite progress to be found in displayed text"
62+
);
63+
} );
64+
5365
QUnit.module( "timing", {
5466
getPreviousTest: function( assert ) {
5567
return document.getElementById( "qunit-test-output-" + assert.test.testId )
@@ -136,7 +148,6 @@ QUnit.test( "logs location", function( assert ) {
136148
);
137149
} );
138150

139-
140151
QUnit.test( "disables autocomplete on module filter", function( assert ) {
141152
var moduleFilterSearch = document.getElementById( "qunit-modulefilter-search" );
142153

0 commit comments

Comments
 (0)