QUnit creating tests is not that simple.

QUnit creating tests is not that simple.

A couple of times I've tried to use QUnit for test support. But my experience is that I'm more busy debugging and trying to fix my QUnit test scripts, than developing functions.
It goes well when using QUnit for testing plain JavaScript libraries, like function X returns something.
But when DOM is involved, or ASync then it's getting fuzzier.

My current problem, without going into details, is that my last test call, is executed as first. Partly because my code is depending on Asynchronous Callbacks. When I repeat the test, its outcome is not always the same. Sometimes I correct a test, I run the tests, al is green. Then immediately I run the test again and some test fails. Like the quirk that the last test is executed first, but is relaying the of the states of previous tests.

QUnit.test(..., function( assert ) {
  var done = assert.async();

console.log('A');

  setTimeout(function() {
    assert.equal( ... );
    done();
  });
});

QUnit.test(..., function( assert ) {
  var done = assert.async();

console.log('B');

  setTimeout(function() {
    assert.equal( ... );
    done();
  });
});

QUnit.test(..., function( assert ) {
  var done = assert.async();

console.log('C');

  setTimeout(function() {
    assert.equal( ... );
    done();
  });
});

Log shows,

C
A
B

Your advice to keep tests Atomic, relying on HTML code in #qunit-fixture is a nice addition, but other external JS libraries, like Google Material Design Lite (MDL) aren't aware of the resets made in the #qunit-fixture container on each new test.

Any ideas or advice or reading material on building robust QUnit test?
Thanks.