I am pulling my hair out with testing Angular. I am trying to instantiate a controller and jasmine complains that $controller is not a function. Below is my test.
describe "MyCtrl test", () ->
beforeEach module('ngRoute')
beforeEach module('myControllers')
$controller = undefined
$scope = undefined
$routeParams = undefined
mySvc = undefined
beforeEach inject (_$controller_, $rootScope, _$routeParams_,_mySvc_) ->
$controller = _$controller_
$scope = $rootScope.$new()
mySvc = _mySvc_
describe "MyCtrl", () ->
beforeEach () ->
MyCtrl = $controller('MyCtrl', {$scope:$scope,$routeParams:$routeParams,mySvc:mySvc})
it "should be defined", () ->
expect(MyCtrl).toBeDefined()
I have defined $controller at the top level scope, I have injected the controller service and assigned it to the global variable. How is it not a function?
Aucun commentaire:
Enregistrer un commentaire