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.