Inject a module into karma test in Angular 1.5

Viewed 1460

I am trying to upgrade my Angular app from 1.3.x to 1.5.1. I have a suite of tests that all ran fine with Karma + PhantomJS when I was at version 1.3.x of Angular, however once I upgraded all of my tests are failing. It appears that the way I was injecting modules into the unit tests before no longer works.

This fails in 1.5:

'use strict'
 App = null

 fdescribe 'App Model', ->
   beforeEach module('MyAngularApp')

   beforeEach inject ($injector)->
     App = $injector.get('App')

 it 'should exist', ->
   console.log 'App:', App
   expect(App).toBeDefined()

I have also tried injecting with the following

 beforeEach inject ($injector, _App_)->
   App = _App_

but my App model is still not being injected.

I have been digging through the documentation on AngularJS 1.5.1 but I didn't see any changes that I need to make with the injector.

In Angular 1.5.x, how can I properly inject a model into my unit tests?

1 Answers
Related