How to extract QUnit results from a document

When QUnit adds the details of the test result to your HTML document, it thoughtfully wraps the number of accepted, passed, and failed tests inside the span elements, each with its own class, so that you can programmatically restore these three numbers. However, although I see gaps in the finished HTML, I cannot find them when I search with

jQuery('span.failed'); // For example 

They are not present during the onload event, although they are intended for the onunload event. I also cannot get them right after the QUnit test () calls.

What am I doing wrong?

+4
source share
2 answers

QUnit offers a callback method that needs to be rewritten: QUnit.done(failures, total)

It is called when the last test is completed, and receives both the number of failed tests and the total number of tests. so you just define

 QUnit.done = function(failures, total) { // do whatever here } 

and what is he.

+3
source

Javascript time can be a bit complicated. Instead of this:

 test(); yourMethod(); 

You might want to try:

 test(); window.setTimeout(yourMethod, 1000); 

Depending on what the problem is exactly, you can even get away with 1 instead of 1000 (but I believe that 1 second is not so scary anyway).

+2
source

Source: https://habr.com/ru/post/1300218/


All Articles