Skip to content

Commit

Permalink
HTML Reporter: Fix reversed order after clicking "Hide passed"
Browse files Browse the repository at this point in the history
Follows-up #1311.

Since QUnit 2.7.0, when viewing a finished test run and turning on
"Hide passed" and then turning it off again, resulted in the same
results being shown again, but in reversed order.

This was because we hide the tests from top to bottom (and push into
the array), but then upon re-inserting them we used pop(), which means
we first append the last test to the end of the page, but then the
before-last is popped after that and appended to what is now the end
of the page, etc. The end result is the tests first displaying from
A-Z, then after toggling on/off, displaying from Z-A.
  • Loading branch information
Krinkle committed Jun 12, 2024
1 parent 331e788 commit 12b4cdb
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/html-reporter/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,8 @@ const stats = {
tests.removeChild(hiddenTest);
}
} else {
let test;
// eslint-disable-next-line eqeqeq
while ((test = hiddenTests.pop()) != null) {
tests.appendChild(test);
while (hiddenTests.length) {
tests.appendChild(hiddenTests.shift());
}
}
}
Expand Down

0 comments on commit 12b4cdb

Please sign in to comment.