javascript - Non-blocking asynchronous tests using QUnit - Stack Overflow

It seems that the QUnit functions stop() and start() allow to wait for asynchronous tests, but during t

It seems that the QUnit functions stop() and start() allow to wait for asynchronous tests, but during that waiting period the whole test suite hangs. Is there a way to run asynchronous tests in a non-blocking fashion using QUnit?

It seems that the QUnit functions stop() and start() allow to wait for asynchronous tests, but during that waiting period the whole test suite hangs. Is there a way to run asynchronous tests in a non-blocking fashion using QUnit?

Share Improve this question edited Dec 16, 2011 at 10:09 Nathan 11.2k4 gold badges40 silver badges50 bronze badges asked Dec 8, 2011 at 12:39 RandomblueRandomblue 116k150 gold badges363 silver badges558 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8 +50

Looking at the docs for asyncTest and stop, there's two reason's I can see that it's set up like that.

  1. So that you aren't accidentally running two tests at a time which might conflict with something (ie, modifying the DOM and so changing each others' test results).
  2. So that QUnit knows when the tests have finished. If it es to the end of all the synchronous tests, then it'll write up the results, which you don't really want it to do if there are still async tests happening in the background.

So these are a good thing, and you probably don't actually want the async tests to not block as they run. You could probably do it by calling start immediately after the start of your async tests, but remember, JavaScript is actually single threaded (even though it sometimes gives the appearance of multi-threading), so this might cause unexpected results, as you can't guarantee when your async test will continue running... it might not (probably won't) be until after the other tests have finished and the results have been published.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745168648a4614788.html

相关推荐

  • javascript - Non-blocking asynchronous tests using QUnit - Stack Overflow

    It seems that the QUnit functions stop() and start() allow to wait for asynchronous tests, but during t

    7小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信