qunitjs / qunit

🔮 An easy-to-use JavaScript unit testing framework.
https://qunitjs.com
MIT License
4.02k stars 784 forks source link

HTML Reporter: Fix reversed order after clicking "Hide passed" #1763

Closed Krinkle closed 3 months ago

Krinkle commented 3 months ago

Follows-up https://github.com/qunitjs/qunit/pull/1311.

This fixes a regression in QUnit 2.7.0. When viewing a finished test run and turning on "Hide passed" and then turning it off again, the second click, reverses the result order.

This was because we hide each test 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, and 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 originally display from A-Z, and are stored in the array from A-Z as well, but then after toggling on/off, get rendered Z-A.