Last active
December 30, 2016 08:03
-
-
Save pirey/07fe56bd92a2a371de223006740c6b63 to your computer and use it in GitHub Desktop.
solution for $httpBackend unexpected requests in jasmine spec for angularjs project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('testing using $httpBackend in ionic app', function() { | |
var yourAsyncService; | |
var $httpBackend; | |
// prepare our service and $httpBackend | |
beforeEach(function() { | |
// load module that holds our service | |
// make sure the required module is loaded | |
module('module_name'); | |
// this solves unexpected $httpBackend requests issue | |
// https://github.com/angular-ui/ui-router/issues/212#issuecomment-76230499 | |
module(function($provide, $urlRouterProvider) { | |
$provide.value('$ionicTemplateCache', function(){} ); | |
$urlRouterProvider.deferIntercept(); | |
}); | |
// get the services | |
inject(function(_$httpBackend_, _yourAsyncService_) { | |
yourAsyncService = _yourAsyncService_; | |
$httpBackend = _$httpBackend_; | |
}); | |
}); | |
// some $httpBackend convention | |
afterEach(function() { | |
$httpBackend.verifyNoOutstandingRequest(); | |
$httpBackend.verifyNoOutstandingExpectation(); | |
}); | |
// your tests here... | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment