Hi Guys,
For a project I'm currently working on I'm using QUnit to do asynchronous tests using start/stop.
There are two major problems I face:
start() is asynchronous, so this wont wait for the last start() call:
stop()
start()
stop()
start()
also things like
stop()
stop()
start()
start()
are not possible.
in the start() function there is a comment:
// A slight delay, to avoid any current callbacks
What current callbacks? The ones of qunit seem to be synchronized() anyway,
and in my opinion it's the users duty to make sure start() is called after all callbacks.
Is there a good reason not to make it synchronous or at least provide a synchronous alternative?
My other problem is that sometimes a callback fires way to late, when another test is already running.
It will then cause indeterministic behaviour (tests randomly fail or pass). A simple way to solve this would be to change blocking to an integer and keep track of the number start/stop calls. So the stop(), stop(), start(), start() would work and it would be possible to detect when there are more start() calls than expected.
A more complex solution to this problem would be to properly scope tests:
scopedTest('sometest', function(context){
context.stop(200);
window.setTimeout(function(){
context.start();
context.ok(true, 'something')
}, 100);
});
The later is probably a bit of work, but IMO very worthwhile. My question there is, would there be interest for such a feature/patch?