I've encountered an unexpected issue while testing a service that returns a standard $q promise. Strangely, none of the promises I test seem to be resolved or rejected (specifically, the handlers from then
are not being called even though the code inside the promise runs without any problems). I've attempted to force a digest on the root scope as suggested in some answers on SO, but to no avail.
Below is a concise example demonstrating the issue:
describe('promise', function(){
jasmine.DEFAULT_TIMEOUT_INTERVAL = 500;
let q;
beforeEach(inject(function($q){
q = $q;
}));
it('finishes', function(done){
expect(q).toBeDefined();
const promise = q.resolve();
console.log(promise);
promise.then(
() => done(),
() => done.fail()
);
});
});
What steps should I take to ensure the promise behaves as expected?