How to extract QUnit results from the document
javascript, jquery, qunit, unit-testing
Solution
QUnit offers a callback-method, which you need to overwrite: `QUnit.done(failures, total)`
It is called when the last test has finished, and gets both the number of failed tests as well we the total number of tests. so you simply define
QUnit.done = function(failures, total) {
// do whatever here
}
and that's it.
Problem
When QUnit adds the test result details to your HTML document, it thoughtfully wraps the numbers of tests taken, passed and failed inside span elements, each with its own class, to let you recover these three numbers programmatically. However, even though I can see the spans in the finished HTML, I can't find them when I search with ``` jQuery('span.failed'); // For example ``` They aren't there during the onload event, although they are for the onunload event. Nor can I get them just after the QUnit test() calls. What am I doing wrong?