当QUnit将测试结果详细信息添加到HTML文档时,它会仔细地包含在span元素内部执行,传递和失败的测试数量,每个元素都有自己的类,以便以编程方式恢复这三个数字。 但是,即使我可以在完成的HTML中看到跨度,但在搜索时我找不到它们
jQuery('span.failed'); // For example它们在onload事件期间不存在,尽管它们用于onunload事件。 在QUnit test()调用之后,我也无法得到它们。
我究竟做错了什么?
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 exampleThey 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?
最满意答案
QUnit提供了一个回调方法,你需要覆盖它: QUnit.done(failures, total)
在最后一次测试完成时调用它,并获得失败测试的数量以及测试总数。 所以你只需定义
QUnit.done = function(failures, total) { // do whatever here }就是这样。
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.
更多推荐
发布评论