How to reset status in QUnit?

Is there a way to reset QUnit tests without reloading the page?

The documentation says that QUnit.init () re-initializes if it has already been initialized, but this does not seem to work. I get a "Run ..." message where the result should be.

http://docs.jquery.com/QUnit

+4
source share
1 answer

Wrap all your tests inside a function.

Call the function when you are ready to run the test.

If you want to restart the test after QUnit completes, then make and call a function like "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. 
+4
source

Source: https://habr.com/ru/post/1398018/


All Articles