Don't immediately move to the next queueable fn on async error
This allows assertion failures and other errors that occcur after the async error to be routed to the correct spec/suite. Previously, Jasmine treated global errors and unhandled promise rejections just like exceptions thrown from a synchronous spec: it recorded the error as a spec failure and moved on. Now, global errors and uhandled rejections are recorded as failures but the current queueable fn will continue until it either signals completion or times out. Global errors and unhandled rejections are different from synchronous exceptions: it's common for the queueable fn that caused them to continue executing. Immediately moving on often meant that the queueable fn would produce expectation failures or other errors when a different spec or suite was running, thus causing those failures to be routed to the wrong place.
This commit is contained in:
@@ -7872,7 +7872,6 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
||||
completedSynchronously = true,
|
||||
handleError = function handleError(error) {
|
||||
onException(error);
|
||||
next(error);
|
||||
},
|
||||
cleanup = once(function cleanup() {
|
||||
if (timeoutId !== void 0) {
|
||||
|
||||
@@ -669,9 +669,13 @@ describe('QueueRunner', function() {
|
||||
jasmine.clock().uninstall();
|
||||
});
|
||||
|
||||
it('skips to cleanup functions on the first exception', function() {
|
||||
it('skips to cleanup functions once the fn completes after an unhandled exception', function() {
|
||||
var errorListeners = [],
|
||||
queueableFn = { fn: function(done) {} },
|
||||
queueableFn = {
|
||||
fn: function(done) {
|
||||
queueableFnDone = done;
|
||||
}
|
||||
},
|
||||
nextQueueableFn = { fn: jasmine.createSpy('nextFunction') },
|
||||
cleanupFn = { fn: jasmine.createSpy('cleanup') },
|
||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||
@@ -686,10 +690,13 @@ describe('QueueRunner', function() {
|
||||
queueableFns: [queueableFn, nextQueueableFn],
|
||||
cleanupFns: [cleanupFn],
|
||||
completeOnFirstError: true
|
||||
});
|
||||
}),
|
||||
queueableFnDone;
|
||||
|
||||
queueRunner.execute();
|
||||
errorListeners[errorListeners.length - 1](new Error('error'));
|
||||
expect(cleanupFn.fn).not.toHaveBeenCalled();
|
||||
queueableFnDone();
|
||||
expect(nextQueueableFn.fn).not.toHaveBeenCalled();
|
||||
expect(cleanupFn.fn).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -89,7 +89,6 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
||||
completedSynchronously = true,
|
||||
handleError = function handleError(error) {
|
||||
onException(error);
|
||||
next(error);
|
||||
},
|
||||
cleanup = once(function cleanup() {
|
||||
if (timeoutId !== void 0) {
|
||||
|
||||
Reference in New Issue
Block a user