4
有没有方法可以在不重新加载页面的情况下重置QUnit测试?如何在QUnit中重置状态?
在文档上说QUnit.init()重新初始化它是否已经被初始化,但这似乎不起作用。 我收到一条消息“Running ...”,其结果应该是。
有没有方法可以在不重新加载页面的情况下重置QUnit测试?如何在QUnit中重置状态?
在文档上说QUnit.init()重新初始化它是否已经被初始化,但这似乎不起作用。 我收到一条消息“Running ...”,其结果应该是。
总结所有的函数内部测试。
当您准备好运行测试时调用该函数。
如果你想在QUnit完成后重新运行测试,然后调用一个函数,如'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.