I'm running BDD tests using the grunt-contrib-jasmine plugin. When I generate the _SpecRunner.html and run the tests through Chrome everything is fine. When I run the tests via PhantomJS I receive error messages which indicate that jQuery is not loaded.
The file that I'm testing uses LABjs to load jQuery, jQueryUI, and few other files that depend on them. This tag will be placed on a third party site so this script is required to load jQuery.
(function(){
function callback() {
$LAB
.script('path_to_jQuerry').wait()
.script('path_to_jQueryUI').wait()
.script('files_that_use_jQuery').wait();
}
loadJS('path_to_LABjs', callback);
})();
Assume that loadJS successfully loads LABjs. Like I said, when I run the tests on this file through the browser there are no errors, but using grunt-contrib-jasmine via PhantomJS I receive the following error before any of my tests complete:
TypeError: 'undefined' is not a function (evaluating '$.publish("foo")')
The code that produces looks like:
(function($) {
$.publish('foo');
})(jQuery);
My initial thought is that PhantomJS isn't compatible with the LABjs script loader or that the code is 'evaluated' but PhantomJS at the wrong time. Snooping around the grunt-contrib-jasmine, jasmine, and phantomjs code hasn't gotten me anywhere.
Any comment is appreciated.