Don't report a deprecation when a promise is resolved to something

beforeEach(() => somePromiseReturningFn()) is likely a common idiom
and we don't want to treat it as an error.

* Fixes #1958
This commit is contained in:
Steve Gravrock
2022-02-19 12:22:55 -08:00
parent 58d13570ac
commit 4059ab7ba6
3 changed files with 100 additions and 2 deletions

View File

@@ -8656,7 +8656,7 @@ getJasmineRequireObj().QueueRunner = function(j$) {
maybeThenable = queueableFn.fn.call(self.userContext);
if (maybeThenable && j$.isFunction_(maybeThenable.then)) {
maybeThenable.then(next, onPromiseRejection);
maybeThenable.then(wrapInPromiseResolutionHandler(next), onPromiseRejection);
completedSynchronously = false;
return { completedSynchronously: false };
}
@@ -8747,6 +8747,16 @@ getJasmineRequireObj().QueueRunner = function(j$) {
}
};
function wrapInPromiseResolutionHandler(fn) {
return function(maybeArg) {
if (j$.isError_(maybeArg)) {
fn(maybeArg);
} else {
fn();
}
};
}
return QueueRunner;
};