Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML Reporter: Update testresult display in QUnit 3.0 #1760

Merged
merged 2 commits into from
Jun 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions src/html-reporter/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -721,29 +721,30 @@ const stats = {
].join('');
}

function msToSec (milliseconds) {
if (milliseconds < 1000) {
// Will return e.g. "0.2", "0.03" or "0.004"
return (milliseconds / 1000).toPrecision(1) + ' seconds';
}
const sec = Math.ceil(milliseconds / 1000);
return sec + (sec === 1 ? ' second' : ' seconds');
}

QUnit.on('runEnd', function (runEnd) {
const banner = id('qunit-banner');
const tests = id('qunit-tests');
const abortButton = id('qunit-abort-tests-button');
const assertPassed = config.stats.all - config.stats.bad;
let html = [
runEnd.testCounts.total,
' tests completed in ',
runEnd.runtime,
' milliseconds, with ',
msToSec(runEnd.runtime),
', with ',
runEnd.testCounts.failed,
' failed, ',
runEnd.testCounts.skipped,
' skipped, and ',
runEnd.testCounts.todo,
' todo.<br />',
"<span class='passed'>",
assertPassed,
"</span> assertions of <span class='total'>",
config.stats.all,
"</span> passed, <span class='failed'>",
config.stats.bad,
'</span> failed.',
' todo.',
getRerunFailedHtml(stats.failedTests)
].join('');
let test;
Expand All @@ -752,7 +753,7 @@ const stats = {

// Update remaining tests to aborted
if (abortButton && abortButton.disabled) {
html = 'Tests aborted after ' + runEnd.runtime + ' milliseconds.';
html = 'Tests aborted after ' + msToSec(runEnd.runtime) + '.';

for (let i = 0; i < tests.children.length; i++) {
test = tests.children[i];
Expand Down