Add explicit fail and move on for async functions

- `done` now has a `fail` property which will call the global `fail`
  then continue to the next function in the queue

[finish #73744618] Fix #567 Fix #568
This commit is contained in:
slackersoft
2014-10-02 08:10:29 -07:00
parent 0c77c6cfb5
commit f4e5573ee3
4 changed files with 41 additions and 0 deletions

View File

@@ -18,6 +18,7 @@ getJasmineRequireObj().QueueRunner = function(j$) {
this.catchException = attrs.catchException || function() { return true; };
this.userContext = attrs.userContext || {};
this.timer = attrs.timeout || {setTimeout: setTimeout, clearTimeout: clearTimeout};
this.fail = attrs.fail || function() {};
}
QueueRunner.prototype.execute = function() {
@@ -63,6 +64,11 @@ getJasmineRequireObj().QueueRunner = function(j$) {
}),
timeoutId;
next.fail = function() {
self.fail.apply(null, arguments);
next();
};
if (queueableFn.timeout) {
timeoutId = Function.prototype.apply.apply(self.timer.setTimeout, [j$.getGlobal(), [function() {
var error = new Error('Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.');