am setting up unit test for Angular application build with webpack how ever am getting this error when am running my first simple test.
TypeError: $controller is not a function
The controller code like this :
(function() {
'use strict';
angular
.module('dpServerV2WebappRev2App.controllers')
.controller('MainCtrl', MainCtrl);
MainCtrl.$inject = ['$scope'];
function MainCtrl($scope) {
$scope.x = 'x';
}
})();
Where the test look like this:
describe('MainCtrl', function () {
beforeEach(module('dpServerV2WebappRev2App.controllers'));
var $controller;
beforeEach(inject(function(_$controller_){
$controller = _$controller_;
}));
describe('$scope.brand', function () {
it('should match the brand portal name', function () {
var $scope = {};
var controller = $controller('MainCtrl', { $scope: $scope });
expect($scope.x).toEqual('x');
});
});
});
Aucun commentaire:
Enregistrer un commentaire