Jasmine Doesn't Inject Services
Solution 1:
I have found that you need to inject your services/factories yourself:
beforeEach(function() {
module('search'));
inject(function(_SearchObject_) {
SearchObject = _SearchObject_;
});
});
That should make the service available to the tests. I just went back and spot checked some of my own tests and saw that this was the common piece all of my factory and service tests had.
Update: After further review, there are some really odd things going on here and possibly multiple issues that need to be resolved. I don't have all of your dependency libraries and the angular module wouldn't load at all in the tests without mocking or removing lazyLoad and httpInterceptor. I'm going to assume that isn't your issue though and the module loads. After that once I mocked out Globals it loads just fine.
So in short, be sure you are properly providing lazyLoad, httpInterceptor, and Globals to the test, either with the actual code or through mocking, and the test passes. At least for me it does.
Post a Comment for "Jasmine Doesn't Inject Services"