Hi, I'm working on my first unit tests for my controllers but each test I've written fails to recognise the main app module in my beforeEach statement, this is one of the tests I've written:
'use strict'; describe('Controller: AppCtrl', function() { beforeEach(module('consultPrototypeApp',[])); it('should have a AppCtrl defined', function() { expect(consultPrototypeApp.AppCtrl).toBeDefined(); }); }); The error message I receive when running grunt test is: C:\Development\Consult>grunt test:unit Running "clean:server" (clean) task Cleaning .tmp...OK Running "concurrent:test" (concurrent) task Running "copy:styles" (copy) task Copied 1 files Done, without errors. Running "autoprefixer:dist" (autoprefixer) task Prefixed file ".tmp/styles/consult.css" created. Running "connect:test" (connect) task Started connect web server on 127.0.0.1:9001. Running "karma:unit" (karma) task INFO [karma]: Karma v0.12.16 server started at http://localhost:8080/ INFO [launcher]: Starting browser Chrome INFO [Chrome 35.0.1916 (Windows 7)]: Connected on socket oSd_DUI8PoKosvyII0oi with id 36631299 Chrome 35.0.1916 (Windows 7) LOG: 'JQMIGRATE: Logging is active' Chrome 35.0.1916 (Windows 7) Controller: AppCtrl should have a AppCtrl defined FAILED ReferenceError: consultPrototypeApp is not defined at null.<anonymous> (C:/Development/Consult/test/spec/controllers/AppCtrlTest.js:9:12) Chrome 35.0.1916 (Windows 7) Controller: PatientSearchCtrl should have show results as false by default FAILED Error: [ng:areq] Argument 'PatientSearchCtrl' is not a function, got undefined http://errors.angularjs.org/1.2.16/ng/areq?p0=PatientSearchCtrl&p1=not%20a%20function%2C%20got%20undefined at C:/Development/Consult/app/bower_components/angular/angular.js:78:12 at assertArg (C:/Development/Consult/app/bower_components/angular/angular.js:1443:11) at assertArgFn (C:/Development/Consult/app/bower_components/angular/angular.js:1453:3) at C:/Development/Consult/app/bower_components/angular/angular.js:7131:9 at null.<anonymous> (C:/Development/Consult/test/spec/controllers/SearchCtrlTest.js:11:25) at Object.invoke (C:/Development/Consult/app/bower_components/angular/angular.js:3869:17) at workFn (C:/Development/Consult/app/bower_components/angular-mocks/angular-mocks.js:2143:20) Error: Declaration Location at window.inject.angular.mock.inject (C:/Development/Consult/app/bower_components/angular-mocks/angular-mock s.js:2128:25) at null.<anonymous> (C:/Development/Consult/test/spec/controllers/SearchCtrlTest.js:9:14) at C:/Development/Consult/test/spec/controllers/SearchCtrlTest.js:3:1 Expected undefined to be false. Error: Expected undefined to be false. at null.<anonymous> (C:/Development/Consult/test/spec/controllers/SearchCtrlTest.js:15:31) Chrome 35.0.1916 (Windows 7): Executed 2 of 2 (2 FAILED) ERROR (0.064 secs / 0.057 secs) Warning: Task "karma:unit" failed. Use --force to continue. Aborted due to warnings. Execution Time (2014-05-29 13:20:08 UTC) concurrent:test 1.8s ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 34% karma:unit 3.5s ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 64% Total 5.4s It looks like the module 'consultPrototypeApp' is not being loaded in correctly, I wonder if the problem is in my karma.conf.js file? Any ideas why this is happening? Thanks Stephen -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscr...@googlegroups.com. To post to this group, send email to angular@googlegroups.com. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.