getting ReferenceError: Can’t find variable: angular

getting ReferenceError: Can’t find variable: angular

Problem

I am new to yeoman and all the tools it uses. I have created a test project in yeoman and trying to run the test spec in jasmine. I have installed the jasmine plugin using cmd:

npm install grunt-contrib-jasmine — save-dev

Added a jasmine task in Gruntfile.js

jasmine: {
src: '<%= yeoman.app %>/scripts/{,*/}*.js',
specs: 'test/spec/{,*/}*.js'
},

when i run the jasmine task grunt jasmine i get following error:-

E:Personal Projectsyeoman-projectstest-app>grunt jasmine
Running "jasmine:src" (jasmine) task

Testing jasmine specs via phantom
ReferenceError: Can't find variable: angular at
......E:Personal%20Projectsyeoman-projectstest-appappscriptsapp.js:3

ReferenceError: Can't find variable: angular at
......E:Personal%20Projectsyeoman-projectstest-appappscriptscontroll
ersmain.js:3

Following is my main.js

'use strict';

angular.module('testAppApp')
.controller('MainCtrl', function ($scope) {
$scope.awesomeThings = [
'HTML5 Boilerplate',
'AngularJS',
'Karma'
];
});

and app.js

'use strict';

angular.module('testAppApp', [
'ngRoute'
])
.config(function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'views/main.html',
controller: 'MainCtrl'
})
.otherwise({
redirectTo: '/'
});
});

Am i missing something ?

Thanks, Parikshit

Problem courtesy of: Parikshit

Solution

under jasmine src you have to include angular.js. For now you have only included you own scripts. If you are using yeaoman, they are usally in a folder called bower_components/angular.

Solution courtesy of: michael

View additional discussion.

getting ReferenceError: Can’t find variable: angular

Posted first on ” JavaScript on Medium “
Author: Angular.js Recipes

Author: Pawan Kumar

Leave a Reply

Close Menu
%d bloggers like this:
Skip to toolbar