Skip to content

Commit

Permalink
HTML Reporter: Fix broken "Rerun without max depth" link
Browse files Browse the repository at this point in the history
Cherry-picked from 91db92d (3.0.0-dev)

Also applies part of 73c03cf, which
extends the link text from "Rerun" to "Rerun without max depth".

Also fixes a mistaken reference to QUnit.config.maxDepth, when the
limit actually used by dump.js is QUnit.dump.maxDepth. The message
correctly stated this already.

Note that in QUnit 3.0, the two are aliases (as of 0a26e2c), so
this discrepancy is only an issue in QUnit 2.x.
  • Loading branch information
Krinkle committed Dec 5, 2024
1 parent f78da46 commit da0c59e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/html-reporter/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -907,10 +907,10 @@ const stats = {
expected.indexOf('[object Object]') !== -1) {
message += "<tr class='test-message'><th>Message: </th><td>" +
'Diff suppressed as the depth of object is more than current max depth (' +
QUnit.config.maxDepth + ').<p>Hint: Use <code>QUnit.dump.maxDepth</code> to ' +
QUnit.dump.maxDepth + ').<p>Hint: Use <code>QUnit.dump.maxDepth</code> to ' +
" run with a higher max depth or <a href='" +
escapeText(setUrl({ maxDepth: -1 })) + "'>" +
'Rerun</a> without max depth.</p></td></tr>';
escapeText(setUrl({ maxDepth: 0 })) + "'>" +
'Rerun without max depth</a>.</p></td></tr>';
} else {
message += "<tr class='test-message'><th>Message: </th><td>" +
'Diff suppressed as the expected and actual results have an equivalent' +
Expand Down
4 changes: 4 additions & 0 deletions src/html-runner/urlparams.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import { window } from '../globals';
// TODO: Move to /src/core/config.js in QUnit 3,
// in accordance with /docs/api/config.index.md#order
QUnit.config.filter = urlParams.filter;
// NOTE: Based on readFlatPreconfigNumber from QUnit 3.
if (/^[0-9]+$/.test(urlParams.maxDepth)) {
QUnit.config.maxDepth = QUnit.dump.maxDepth = +urlParams.maxDepth;
}
QUnit.config.module = urlParams.module;
QUnit.config.moduleId = [].concat(urlParams.moduleId || []);
QUnit.config.testId = [].concat(urlParams.testId || []);
Expand Down
5 changes: 4 additions & 1 deletion test/main/dump.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
/* eslint-disable qunit/no-conditional-assertions */

QUnit.module('dump', {
beforeEach: function () {
QUnit.dump.maxDepth = 0;
},
afterEach: function () {
// Restore default
QUnit.dump.maxDepth = null;
QUnit.dump.maxDepth = 5;
}
});

Expand Down

0 comments on commit da0c59e

Please sign in to comment.