I'm trying to test my application with Karma but I get following Errors:
minErr/<@/home/usr/webui-ng/src/client/app/bower_components/angular/angular.js:78:5
loadModules/<@/home/usr/webui-ng/src/client/app/bower_components/angular/angular.js:3859:1
forEach@/home/usr/webui-ng/src/client/app/bower_components/angular/angular.js:325:7
loadModules@/home/usr/webui-ng/src/client/app/bower_components/angular/angular.js:3824:5
createInjector@/home/usr/webui-ng/src/client/app/bower_components/angular/angular.js:3764:3
workFn@/home/usr/webui-ng/src/client/app/bower_components/angular-mocks/angular-mocks.js:2150:9
These are my files:
hello.js
angular.module('myApp', [])
.controller('MainController', function($scope) {
$scope.name = "Ari";
$scope.sayHello = function() {
$scope.greeting = "Hello " + $scope.name;
}
})
hello.js - test file :
describe('Unit: MainController', function() {
// Load the module with MainController
beforeEach(module('myApp'));
var ctrl, scope;
// inject the $controller and $rootScope services
// in the beforeEach block
beforeEach(inject(function($controller, $rootScope) {
// Create a new scope that's a child of the $rootScope
scope = $rootScope.$new();
// Create the controller
ctrl = $controller('MainController', {
$scope: scope
});
}));
it('should create $scope.greeting when calling sayHello',
function() {
expect(scope.greeting).toBeUndefined();
scope.sayHello();
expect(scope.greeting).toEqual("Hello Ari");
});
});
As you can see, I've already loaded the module, as the solution was in Controller undeclared in Jasmine test.
What else could it be? I haven't found much about these errors on the web. I would be very happy to finally find an answer for that.