lundi 30 mai 2016

Promise.resolve().then not working in jasmine test

I'm trying to setup a test which involves promises. Here is my example code:

var promise;

beforeEach(inject(function ($q) {
    promise = $q.resolve();
}));

it('should resolve', function (done) {
    promise.then(function () {
        expect(true).toBeTruthy();
        done();
    });
});

DEMO

For some reason, when I run this, I get a TIMEOUT

Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.

Why doesn't the promise execute the callback given to then ?

Cheers

Aucun commentaire:

Enregistrer un commentaire