I am trying to run the Jasmine Unit test on a factory that I created in Angular JS.
Here is my app.js
var app = angular.module('myApp', [
'ngRoute'
]);
Here is services.js
app.factory('Service', function(){
var service = {
one: function(){
return 1;
}
};
return service;
})
Here is the Karma config file
files: [
'public/bower_components/angular/angular.js',
'public/bower_components/angular-mocks/angular-mocks.js',
'public/js/app.js',
'public/js/controllers.js',
'public/js/services.js',
'test/**/*test.js'
],
And here is the test
'use strict';
(function () {
describe('myApp', function () {
beforeEach(module('myApp'));
it('testing the service', inject(function (Service) {
console.log(Service)
}));
});
})();
I am really stuck and don’t know where to go now :( All the correct scripts are loaded into the browser. Also, the application works as usual in the browser, so the factory service is fine.
The error message says:
Error: [$injector:modulerr] Failed to instantiate module myApp due to:
Error: [$injector:modulerr] Failed to instantiate module ngRoute due to:
Error: [$injector:nomod] Module 'ngRoute' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
source
share