How to detect when all tests within a QUnit module is completed?

你说的曾经没有我的故事 提交于 2019-12-08 04:13:31

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!