I have recently updated from 1.5 to 1.6.3 and have code where I am using deferred promise objects using the $q service which is now throwing the following errors in my unit test runs:
Possibly unhandled rejection: undefined thrown
Here is the typical structure of a function I have in my code that uses a deferred promise:
public someFunction = () => {
const deferred = this.$q.defer();
if (someConditionIsTrue) {
this.myService.getThings().then((response) => {
deferred.resolve(response);
});
} else {
deferred.reject();
}
return deferred.promise;
};
When unit testing the else condition I get this error thrown (using karma\jasmine\phantomJS)
I already have the following configured also:
config(['$qProvider', ($qProvider) => {
$qProvider.errorOnUnhandledRejections(false);
}])
Can someone point me in the right direction please?
Thanks