diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index db0a01ae..ae5618a0 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -1311,10 +1311,13 @@ getJasmineRequireObj().QueueRunner = function() { for(iterativeIndex = recursiveIndex; iterativeIndex < length; iterativeIndex++) { var fn = fns[iterativeIndex]; if (fn.length > 0) { - attempt(function() { + var attemptSuccessful = attempt(function() { fn.call(self, function() { self.run(fns, iterativeIndex + 1); }); }); - return; + + if(attemptSuccessful) { + return; + } } else { attempt(function() { fn.call(self); }); } @@ -1332,6 +1335,7 @@ getJasmineRequireObj().QueueRunner = function() { function attempt(fn) { try { fn(); + return true; } catch (e) { self.onException(e); if (!self.catchException(e)) { @@ -1339,6 +1343,7 @@ getJasmineRequireObj().QueueRunner = function() { //use a finally block to close the loop in a nice way.. throw e; } + return false; } } }; diff --git a/spec/core/QueueRunnerSpec.js b/spec/core/QueueRunnerSpec.js index da603fd9..e6edf96b 100644 --- a/spec/core/QueueRunnerSpec.js +++ b/spec/core/QueueRunnerSpec.js @@ -102,6 +102,18 @@ describe("QueueRunner", function() { expect(function() { queueRunner.execute(); }).toThrow(); }); + it("continues running the functions even after an exception is thrown in an async spec", function() { + var fn = function(done) { throw new Error("error"); }, + nextFn = jasmine.createSpy("nextFunction"); + + queueRunner = new j$.QueueRunner({ + fns: [fn, nextFn] + }); + + queueRunner.execute(); + expect(nextFn).toHaveBeenCalled(); + }); + it("calls a provided complete callback when done", function() { var fn = jasmine.createSpy('fn'), completeCallback = jasmine.createSpy('completeCallback'), diff --git a/src/core/QueueRunner.js b/src/core/QueueRunner.js index fe7d7592..85dfea3c 100644 --- a/src/core/QueueRunner.js +++ b/src/core/QueueRunner.js @@ -20,10 +20,13 @@ getJasmineRequireObj().QueueRunner = function() { for(iterativeIndex = recursiveIndex; iterativeIndex < length; iterativeIndex++) { var fn = fns[iterativeIndex]; if (fn.length > 0) { - attempt(function() { + var attemptSuccessful = attempt(function() { fn.call(self, function() { self.run(fns, iterativeIndex + 1); }); }); - return; + + if(attemptSuccessful) { + return; + } } else { attempt(function() { fn.call(self); }); } @@ -41,6 +44,7 @@ getJasmineRequireObj().QueueRunner = function() { function attempt(fn) { try { fn(); + return true; } catch (e) { self.onException(e); if (!self.catchException(e)) { @@ -48,6 +52,7 @@ getJasmineRequireObj().QueueRunner = function() { //use a finally block to close the loop in a nice way.. throw e; } + return false; } } };