injector already created. can not register a module

If you are mixing calls to module('someApp') and inject($someDependency) you will get this error.

All your calls to module('someApp') must occur before your calls to inject($someDependency).


You're using the inject function wrong. As the documentation states, the inject function already instantiates a new instance of $injector. My guess is that by passing $injector as a argument to the inject function you are asking it to instantiate the $injector service twice.

Just use inject to pass in the service you want to check. Underneath the covers, inject will use the $injector service it instantiates to grab services.

You can fix this problem by changing the second beforeEach statement to:

beforeEach(inject(function(_authorService_) {
    authorService = _authorService_;
}));

One other thing to note. The argument authorService passed to the inject function has been wrapped with '_' so it's name does not hide the variable created within the describe function. Thats also documented in the inject documentation.