Non-Blocking Asynchronous Tests Using QUnit

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

+4
source share
1 answer

Looking at the docs for asyncTest and stop , there are two reasons why I can understand that it is configured like this.

  • So that you do not accidentally run two tests at the same time, which could conflict with something (i.e. modify the DOM and thereby change the test results of each other).
  • So QUnit knows when the tests will end. If it comes to the end of all synchronous tests, then they will record results that you really do not want if asynchronous tests still occur in the background.

So, that’s good, and you probably don’t really want asynchronous tests to block when they run. Perhaps you could do this by invoking start immediately after running your asynchronous tests, but remember that JavaScript is actually single-threaded (although it does multithread sometimes), so this may lead to unexpected results, since you cannot guarantee that your asynchronous test will continue to work ... it may not be (maybe not) until the other tests are complete and the results are published.

+8
source

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


All Articles