Search code examples
javascriptasynchronousunderscore.jsqunit

Using _.delay with qunitjs and underscore


I want to set a delay in my unit test so that my script can run completely since some parts of my code are async, but it seems that qunit ignores my setTimeout and keeps on waiting for a start()

So i boiled it down to this

asyncTest('setTimeout', 1, function(){

    _.delay(function(){
        start();
        alert('I want to be called stanly');
        ok(1);
    }, 250);
}

This doesn't seem to fire whenever I load my page.

So obviously this isn't the proper way to use delays in QunitJS. My question is how would be the proper way if at all.

EDIT:

I am using a number of libraries:

Qunit
Sinon
Sinon-qunit
jQuery
backbone
underscore
bootstrap

Solution

  • It turns out you should not use qunit and sinon-qunit next to each other since this isn't a plugin. Once you remove sinon-qunit everything should run normally.