1

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.

2
  • What is a angular.js version you are using? Commented Jul 17, 2014 at 9:08
  • Please ensure that the hello.js (the real code) is really included in a karma.conf.js Commented Jul 17, 2014 at 9:21

1 Answer 1

1

As runTarm mentioned, the path in the karma.conf.js was not set to the actual path of the script file (hello.js).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.