问题
For the purposes of test sequencing as well as preventing a test being interrupted.
Also, is there any way to stop a module or test midway and reset QUnit (including all history results)?
QUnit.moduleDone was the only thing I tried for testing module complete. But it applies for every single test within the module, not just the module as a whole.
回答1:
It depends on whether QUnit is running when the tests are declared. If you stop it, declare all the tests, then start it the moduleDone
callback will be triggered once at the end of the module. If it's running while declaring the tests then the tests will be run as soon as they're declared, causing the module to only contain the tests that have been declared so far and it believes the modules done after each test finishes.
The same problem occurs with the done
callback, if QUnit is running while tests are being declared this is continuously triggered.
So if you're using either of these callbacks you really need to either load all tests synchronously in the head, so they exist when QUnit autostarts in the load event, or set QUnit.config.autostart = false
and not call QUnit.start
until all asynchronously loaded scripts have finished declaring their tests.
回答2:
Are you sure about QUnit.moduleDone? For me it is called once at the end of the module; what you are describing sounds like QUnit.testDone.
As for stopping QUnit and resetting it, what would want the web page would look like afterwards?
来源:https://stackoverflow.com/questions/8830032/how-to-detect-when-all-tests-within-a-qunit-module-is-completed