Hide successful tests in QUnit
I am using QUnit as TDD framework for my JavaScript development. It’s not as nice as NUnit is for .NET or SimpleTest for PHP, but it’s really easy to get started with.
However, QUnit lists all tests after a run, not just the failing ones. With just a few tests, it looks like this:
As you can see, QUnit lists all executed tests by default, even the ones that is successfully executed.
This report only includes 14 tests. Imagine having a hundred tests - it would become unmanagable. I’d prefer to only see failing tests by default.
To fix this, I devided to hack jQuery a bit (applies to jQuery 1.4.2):
- Open
qunit.js
. - Find the block that begins with
var li = document.createElement("li");
. - Wrap the entire block in
if (bad) { ... }
.
This makes QUnit only append “bad” tests to the list, which makes the result look like this:
If you know of a built-in way of making QUnit behave like this, please leave a comment below.