qunitjs / qunit

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

HTML Reporter: Update testresult display in QUnit 3.0 #1760

Closed Krinkle closed 1 month ago

Krinkle commented 1 month ago

QUnit 2.21.0:

254 tests completed in 912 milliseconds, with 0 failed, 7 skipped, and 4 todo. 819 assertions of 823 passed, 4 failed.

New:

254 tests completed in 0.9 seconds, with 0 failed, 7 skipped, and 4 todo.

Remove raw assertion count

In short, assertions are too low-level and include confusing/distracting mention of failures that are not actually failures (but assertions in a todo test). Plus, it competes for attention and space when there is already a summary that is adequate on its own.

See also https://qunitjs.com/api/callbacks/QUnit.done/ for why we discourage the details parameter to the QUnit.done() event.

The raw data remains available via QUnit.config.stats.{all,bad} for use in integrations and plugins, although this is undocumented and not encouraged. The recommendation is to use the runEnd and its stable test counts instead, https://qunitjs.com/api/callbacks/QUnit.on/#the-runend-event.

Report time as seconds

This is a more human-scale number. Rounding is opionated. I went with 1 digit of precision, and thus reporting 123ms as 0.1s. For number smaller than 100ms, I opted for a longer format with at always 1 significant digit, so reporting 20ms as 0.02s, instead of e.g. forcefully rounding either down to a confusing "0.0s" or a deceptively high "0.1s". It allows for a little pride/recognition of small numbers.