I am having trouble getting unit tests working for an Angular JS app using Jasmine and RequireJs. I have created a Plunker here
The problem I am having is around the creation of a module. If I include the setup for the Angular module in my controller, like so (see Controller.js in Plunker):
angular.module('catalogManagementApp', []);
then everything works fine. However, this module is created in another file, so this won’t work. So if I try and setup the module in my test using the Angular Mocks module function I get an error saying "No module: catalogManagementApp".
If you look at the ControllerTests.js file, this makes sense because RequireJS is loading the Controller before my call to Angular Mocks to create the module:
beforeEach(module('catalogManagementApp'));
However, I am not sure how to get this working. As you can see from the commented out code in the ControllerTests.js file I have tried moving the require call for the Controller to after the call to setup the module, but this causes the Jasmine test runner to fail and still the same no module error.
The running of Jasmine with RequireJs code was adapted from this