We still want to provide better support for async testing. We have several options for implementing this, though they all come down to getting rid of methods within the test context.
Some ideas:
// async() returns done callback
test(..., function(assert) {
// async() can be invoked multiple times, each callback has to be invoked
var done = assert.async();
setTimeout(function() {
done();
});
});
// this makes integration of Promises very easy
test( ..., function( assert ) {
/* ... */
APP.foo().always( assert.async() ).done( function () {
assert.ok(true);
} );
APP.bar().always( assert.async() ).done( function () {
assert.ok(true);
} );
});
// all tests are async, always have to explicitly end the test, async or not
test(..., function(assert) {
assert.end();
});
// expect sets up async test, finishes when number of assertions ran
test(..., function(assert) {
// makes this test async
expect(1);
setTimeout(function() {
// expected 1 assertion, continue with other tests
// any other assertions will fail this test
assert.ok(true);
});
// return a promise from the test
[...]
For the last one, see #634
Frameworks that are good references: mocha, nodeunit. We could force calling done like nodeunit, always or depending on configuration.
Related: #374
This replaces #331, to have a fresh start on this discussion.
We still want to provide better support for async testing. We have several options for implementing this, though they all come down to getting rid of methods within the
testcontext.Some ideas:
For the last one, see #634
Frameworks that are good references: mocha, nodeunit. We could force calling done like nodeunit, always or depending on configuration.
Related: #374
This replaces #331, to have a fresh start on this discussion.