I'm using QUnit in conjunction with require.js for unit-testing a backbone.js application. All of the tests are asynchronous, using the asyncTest
method.
I'm using setup
and teardown
to build and remove a fixture for each test. My problem is that although asyncTest
seems to be blocking, setup()
gets called for each test before they start, pretty much all setup()
calls run at the same time. This solution doesn't seem to fix my problem. Below I have an example of how I set up the module and here's a link to a test repository that illustrates the problem
My question is: Am I doing something wrong or is this QUnit's normal behaviour?
module('Module', {
setup: function(){
console.log('setup');
},
teardown: function(){
console.log('teardown');
}
})
asyncTest('Test 1', function() {
setTimeout(function(){
equal(2, 2, 'The return should be 2.');
start();
}, 400);
});
asyncTest('Test 2', function() {
setTimeout(function(){
equal(1, 1, 'The return should be 1.');
start();
}, 400);
});