I have a large angularjs project ordered by features. I'd like to setup unit testing but I'm having trouble getting the karma.conf.js file ordering setup.
I tried specifying a simple glob pattern like **/*.js but many of my modules failed to load due to the ordering that they're included in Karma when ran. As I understand, it's alphabetical, first match.
I was able to resolve this by manually figuring out the ordering by doing something like this:
// list of files / patterns to load in the browser files: [ // External scripts 'bower_components/angular/angular.js', 'bower_components/angular-mocks/angular-mocks.js', 'bower_components/angular-cookies/angular-cookies.js', 'bower_components/angular-resource/angular-resource.js', 'bower_components/angular-route/angular-route.js', // NOTE: ORDER IS IMPORTANT // Modules: load module first, then all controllers, services, etc 'scripts/module1/module1.js', 'scripts/module1/**/*.js', 'scripts/module2/module2.js', 'scripts/module2/**/*.js', // Load overall app module last 'scripts/app.js', // Load mocks and tests 'test/mock/**/*.js', 'test/spec/**/*.js' ],
This seems like it will be cumbersome to maintain over time as new modules are added. Is there a way to automatically resolve the ordering?
Note: One possible solution I was thinking was to concat all the files together but I googled to see if others are doing this and found no examples.