Skip to content

Commit

Permalink
Display progress and runtime while test suite is executing (#1398)
Browse files Browse the repository at this point in the history
Closes #1394
  • Loading branch information
jerrypopsoff authored and stefanpenner committed Jun 18, 2019
1 parent 837af39 commit cc1fdb6
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
28 changes: 27 additions & 1 deletion reporter/html.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import QUnit from "../src/core";
import Test from "../src/test";
import { extractStacktrace } from "../src/core/stacktrace";
import { now } from "../src/core/utilities";
import { window, navigator } from "../src/globals";
import "./urlparams";

Expand Down Expand Up @@ -735,6 +737,29 @@ export function escapeText( s ) {
return nameHtml;
}

function getProgressHtml( runtime, stats, total ) {
var completed = stats.passedTests +
stats.skippedTests +
stats.todoTests +
stats.failedTests;

return [
"<br />",
completed,
" / ",
total,
" tests completed in ",
runtime,
" milliseconds, with ",
stats.failedTests,
" failed, ",
stats.skippedTests,
" skipped, and ",
stats.todoTests,
" todo."
].join( "" );
}

QUnit.testStart( function( details ) {
var running, bad;

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

Expand Down
13 changes: 12 additions & 1 deletion test/reporter-html/reporter-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ QUnit.test( "running test name displayed", function( assert ) {
);
} );

QUnit.test( "running test suite progress displayed", function( assert ) {
assert.expect( 1 );

var displaying = document.getElementById( "qunit-testresult" );

var expected = /\d+ \/ \d+ tests completed in \d+ milliseconds, with \d+ failed, \d+ skipped, and \d+ todo./;
assert.ok(
expected.test( displaying.innerHTML ),
"Expect test suite progress to be found in displayed text"
);
} );

QUnit.module( "timing", {
getPreviousTest: function( assert ) {
return document.getElementById( "qunit-test-output-" + assert.test.testId )
Expand Down Expand Up @@ -136,7 +148,6 @@ QUnit.test( "logs location", function( assert ) {
);
} );


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

Expand Down

0 comments on commit cc1fdb6

Please sign in to comment.