I'm trying to understand how to work with async functions in Jasmine, so I've made a simple test:
describe('Promise testing', function() {
beforeEach(module('task6'));
var $rootScope, $resource;
beforeEach(inject(function(_$rootScope_, _$resource_) {
$rootScope = _$rootScope_;
$resource = _$resource_;
}));
it('tests $resource queries', function(done) {
$resource('users.json').query().$promise
.then(function() {
console.log('users');
expect(false).toBe(true);
done();
})
.catch(function() {
console.log('Error');
done();
});
$rootScope.$digest();
});
});
And it always fails with an "Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL." the users.json file is in the same folder with the test. Why is it failing? :)
Aucun commentaire:
Enregistrer un commentaire