[英]How to reset status in QUnit?
有没有一种方法可以在不重新加载页面的情况下重置QUnit测试?
在文档中,它说QUnit.init()如果已经初始化则重新初始化,但这似乎不起作用。 我收到一条消息“正在运行...”,结果应该是。
将所有测试包装在一个函数中。
准备好运行测试时调用该函数。
如果你想在QUnit完成后重新运行测试,那么make并调用一个类似'rerunQUnitTest'的函数。
var runAllTest = function(){
test( "test 1", function(){
var a = true;
equal( a, true, "function a should return false" );
});
};
// call rerunQUnitTest to reset and run your tests again.
var rerunQUnitTest = function(){
QUnit.reset(); // should clear the DOM
QUnit.init(); // resets the qunit test environment
QUnit.start(); // allows for the new test to be captured.
runAllTest(); // runs your functions that has all the test wrapped inside.
};
runAllTest(); // auto runs your tests.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.