I am trying to get Jasmine to work with my Angular JS Project But I always keep getting the following error. I am trying to get it to run a very very simple test. Also I have setup the angular js project using RequireJS. I have given my code below.
The Error I get is :
My Very Simple TestSpec is as given below :
describe('Controller:UserController', function () {
var scope,controller;
beforeEach(function () {
module('app');
inject(function ($controller,$rootScope) {
scope = $rootScope.$new();
controller = $controller('UserController', { '$scope': scope });
});
});
it('checks the troller name', function () {
expect(scope.name).toBe('Superhero');
});
});
And My Controller code is as given below :
define(['app','WebCallManager'], function (app) {
app.controller('UserController', function ($scope,$location,webcallService) {
$scope.name = 'Superhero';
$scope.loginUser = function(){
console.log("Login User Called...");
$location.path('/login').replace();
console.log("View Navigated...");
};
$scope.slidePanel = function(){
f7.openPanel('left');
};
$scope.doWebCall = function(){
console.log("Doing the Web Call...");
webcallService.sendGetRequest();
};
});
});
And the TestRunner.html is :
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Jasmine Test Runner v2.0.1</title>
<link rel="shortcut icon" type="image/png" href="framework/lib/jasmine-2.0.1/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="framework/lib/jasmine-2.0.1/jasmine.css">
<!-- Jasmine/Angular testing framework libraries -->
<script type="text/javascript" src="framework/lib/jasmine-2.0.1/jasmine.js"></script>
<script type="text/javascript" src="framework/lib/jasmine-2.0.1/jasmine-html.js"> </script>
<script type="text/javascript" src="framework/lib/jasmine-2.0.1/boot.js"></script>
<script type="text/javascript" src="framework/lib/angular.js"></script>
<script type="text/javascript" src="framework/lib/angular-mocks.js"></script>
<!-- include source files here... -->
<script data-main="main" src="framework/lib/require.js"></script>
<!-- include spec files here... -->
<script type="text/javascript" src="UserControllerTest.js"></script>
</head>
<body>
</body>
</html>
and my main.js file used to load the requirejs dependencies is :
(function() {
require.config({
baseUrl: "../www/scripts",
// alias libraries paths
paths: {
'angular': '../libs/angular',
'angular-route': '../libs/angular-route',
'angular-animate':'../libs/angular-animate',
'angular-mocks':'../libs/angular-mocks',
'angularAMD': '../libs/angularAMD.min',
'Framework7':'../libs/framework7',
'UserController':'controller/UserCtrl',
'WebCallManager':'services/WebCallManager'
},
// Add angular modules that does not support AMD out of the box, put it in a shim
shim: {
'angularAMD': ['angular'],
'angular-route': ['angular'],
'angular-animate':['angular'],
'angular-mocks':['angular'],
'Framework7':{exports: 'Framework7'}
},
//kick start application
deps: ['app']
});
require(['Framework7'], function(Framework7) {
f7 = new Framework7({
modalTitle: 'Seed App',
swipePanel: 'left',
animateNavBackIcon: true
});
return {
f7: f7
};
});
})();
I have also given the entire source for my seed project here. I would much appreciate it if anyone could help me out.