Reputation: 1304
I'm needing to setup some integration tests in AngularJS using Karma/Jasmine but having trouble, because when not using ngMock (since I want to hit the actual $http endpoints), there are no module
or inject
methods.
So how do I inject services into my tests?
I've tried angular.injector.invoke(...)
but can't get it working, always comes back with an error like Unknown provider: AuthServiceProvider <- AuthService
.
Thoughts?
Upvotes: 3
Views: 407
Reputation: 16302
Try this
'use strict';
describe('Login User', function () {
var app, LoginService;
beforeEach(module('app')) ;
beforeEach(inject(function(_LoginService_) {
LoginService = _LoginService_;
})) ;
it('Should be logged in', function () {
var isLoggedIn = LoginService.isUserLoggedIn();
expect(isLoggedIn).toBeTruthy();
});
});
Upvotes: 2