I'm in the process of setting up a unit testing environment for my project and encountering some difficulties. Specifically, I am attempting to utilize Testacular with Jasmine to test my AngularJS code.
One of the challenges I am facing involves a module named Services
which contains a factory method called KeepAlive. Below is its configuration:
angular.module('services', []).factory('KeepAlive', ['$rootScope', function($rootScope){
//Implementation
}]);
This module is linked to another module called MainModule
. The following snippet displays its structure:
angular.module('MainModule', ['filters', 'services', 'directives', 'ui'])
.config(['$httpProvider', function($httpProvider){
//Configuration
}]).run(['$rootScope', '$timeout', '$routeParams', 'KeepAlive', function($rootScope, $timeout, $routeParams, KeepAlive){
//Execution
}]);
Now, I am looking to incorporate this code into my tests. Here's how my testacular file setup looks:
JASMINE,
JASMINE_ADAPTER,
'assets/lib/jquery/jquery-1.7.1.js',
'assets/lib/angular/angular.js',
'assets/lib/angular/angular-ui.js',
'jsTests/MockingLib/angular-mocks.js',
'assets/scripts/modules/Admin.js',
'assets/scripts/modules/MainModule.js',
'assets/scripts/services/KeepAlive.js',
'assets/scripts/services/Admin.js',
'assets/scripts/filters.js',
'assets/scripts/directives.js',
'assets/scripts/controllers/admin/*.js',
However, I am encountering an error in my testacular console. The error message reads as follows:
Error: Unknown provider: KeepAliveProvider <- KeepAlive
at Error (<anonymous>)
at d:/Work/Workspace/TalentNetwork/assets/lib/angular/angular.js:2627:8
... more stack trace ...
In addition, here is a sample Jasmine test case:
beforeEach(function () {
admin = module("MainModule");
module("services");
});
I am unsure about what I may be missing in my setup. Any assistance would be greatly appreciated as I am new to working with testacular. Thank you in advance.