javascript - How do I make QUnit block until a module is complete? -


i'm trying use qunit test bunch of javascript. code looks this:

module("a"); doexpensivesetupformodulea(); asynctest("a.1", testa1); asynctest("a.2", testa3); asynctest("a.3", testa3);  module("b"); doexpensivesetupformoduleb(); asynctest("b.1", testb1); asynctest("b.2", testb3); asynctest("b.3", testb3); 

if run as-is, doexpensivesetupformoduleb() runs while async tests running, causing failures.

if doexpensivesetupformoduleb() run before testa*, tests either fail or undo expensive setup work testb* fails.

is there way have qunit block on next module? or have block starting new test until previous asynchronous test has completed? or there better framework js testing should using?

note: understand unit tests not atomic. have cleanup code helps make sure don't dirty state, doexpensivesetupfor*() prohibitively expensive, such wouldn't realistic run before each test.

could use module lifecycle?

function runonlyonce(fn) {     return function () {         try {             if (!fn.executed) {                 fn.apply(this, arguments);             }         } {             fn.executed = true;         }     } }  // http://api.qunitjs.com/module/ module("b", {     setup: runonlyonce(doexpensivesetupformoduleb) }); 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -