AngularJS setup
Hi,
Is there a simple set of instructions to test AngularJS using Jasmine ? We have a complicated requireJS setup for testing our entire applications. But I am trying to code a simple test. So the minimum AngularJS configuration is sufficient.
Update :
Do I have to install these ?
'app/bower_components/angular/angular.js',
'app/bower_components/angular-route/angular-route.js',
'app/bower_components/angular-mocks/angular-mocks.js',
I setup an AngularJS projects and Jasmine specs. execute. But this doesn't.
describe('Testing', function() {
var scope;
beforeEach(function (){
//load the module
module('test');
inject(function($compile, $rootScope) {
scope = $rootScope.$new();
});
});
it('Should set date', function() {
scope.date = '10/01/2015';
});
});
Thanks,
Mohan
Please sign in to leave a comment.
what do you mean saying that 'it doesn't'? What errors do you see (if any)? What does your karma configuration file look like?
I'm attaching a project that shows the minimal required configuration
Attachment(s):
angular_karma.zip
I created an AngularJS project in the IDE. Now I have a new folder 'lib' inside which I placed the angular files.
I see this.
ReferenceError: module is not defined
at Object.<anonymous> (C:/Users/476458/WebstormProjects/AngularJS/test/basic/testSpec.js:12:9)
Usually such error means that angular-mocks.js is missing/not included in karma.config/included in wrong order (as 'module' is defined in the
angular-mocks.js). Does the project I've provided work for you?