archives

« Bugzilla Issues Index

#1716 — Add async tests facilities


Promises are coming as part of an agreement between W3C/DOM folks and TC39. They're being used in some W3C specs and FirefoxOS implements them and want to ship them [1] very soon.
In order to avoid yet another de facto standard, we need tests. In order to have async test, we need support for async tests in the test harness. Domenic suggested a done() facility à la Mocha [2] and it feels like a good idea.

It unfolds like this:

test(function(done){

var r = Math.random();

setTimeout(function(){
if(r < 0.5)
done() // test success
else
done(new Error('wtf')) // test failure

}, 1000);

})


[1] https://bugzilla.mozilla.org/show_bug.cgi?id=897913
[2] https://mail.mozilla.org/pipermail/es-discuss/2013-August/032524.html


As of 2014-Jul-17, this has landed in current test262.py -- see

https://github.com/niksurya/test262/commit/9aa6b917fa1ee33993899c984199e02e3ab4a9e9