I have a script that looks like this:
angular.module('Game').constant('WHITE_PIECE', '\u26C0')
... more lines ...
.constant('WHITE_KING', '\u26C1')
(end of file)
When I run grunt jasmine
, I get the classic error, Module 'Game' is not available! You either misspelled...
. Oddly though, I'm positive that module is being declared. If I move the code to the end of the file where the 'Game'
module is declared, it works. If I move the code to the end of a different file, which declares a service for the 'Game'
module, it works. I get no errors in my browser. Is this phantomjs being dumb? Is it a bug in Grunt-contrib-jasmine?
I put console.log statements before this file and before the file which declares the Game module; this showed that the constants file is being interpreted before the Game file. However, I thought Angular was clever enough to figure that out. Do I need to tell grunt-jasmine-contrib exactly which order to load my scripts?
Based on more Googling, I believe this to be a bug and not a mistake. The only solution is to force the correct order of script interpretation, which unfortunately negates the convenience of the jasmine globstar source pattern (e.g. **/*.js
).