Commit 73936741 authored by Daniel Shumway's avatar Daniel Shumway

feat: Add `then` method

- allows attaching to a test finishing
parent 50aac984
......@@ -110,16 +110,8 @@ var Suite = (function () {
return Promise.reject(error);
});
//Wire callback separately so that `_that.promise` will still be rejected
_that.promise.then(function () {
_that.callback.call(that, that);
}, function () {
if (_that.status === STATUS.SKIPPED) { return; }
_that.callback.call(that, that);
}).catch(function (err) { //Polyfill while waiting for https://github.com/nodejs/node/pull/8217
console.log('Uncaught error in suite callback:\n', err);
process.exit(1);
});
//Auto-attach reporter to `that` callback.
that.then(_that.callback);
}
Suite._prototype = {
......@@ -206,6 +198,28 @@ var Suite = (function () {
return suite;
},
then : function (callback) {
var that = this,
_that = this[PRIVATE];
//Allow passing blank? Not sure why, but I'll allow it.
if (typeof callback !== 'function') {
callback = function () {};
}
_that.promise.then(function () {
callback.call(that, that);
}, function () {
if (_that.status === STATUS.SKIPPED) { return; }
callback.call(that, that);
}).catch(function (err) { //Polyfill while waiting for https://github.com/nodejs/node/pull/8217
console.log('Uncaught error in suite callback:\n', err);
process.exit(1);
});
return that;
},
};
return Suite;
}());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment