Skip to content

Instantly share code, notes, and snippets.

@asci
Last active August 29, 2015 14:27
Show Gist options
  • Save asci/128b2787af092d3acb68 to your computer and use it in GitHub Desktop.
Save asci/128b2787af092d3acb68 to your computer and use it in GitHub Desktop.
angular $q is not working in test env
var inject = angular.mock.inject;
var $q;
describe('$q is really strange', function (){
beforeEach(inject(function ($injector){
$q = $injector.get('$q');
}));
it('should proof that q is working properly', function (done){
var lastRequest = $q.defer();
setTimeout(function (){
lastRequest.resolve('my-value');
}, 300);
lastRequest.promise
.then(iAmDone);
function iAmDone(val) {
console.log('======================resolved val======================');
console.log(val);
done();
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment