如何从文档中提取QUnit结果(How to extract QUnit results from the document)

编程入门 行业动态 更新时间:2024-10-27 12:30:41
如何从文档中提取QUnit结果(How to extract QUnit results from the document)

当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 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?

最满意答案

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.

更多推荐

本文发布于:2023-08-07 23:19:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1466169.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文档   QUnit   extract   results   document

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!