I’m using Backbonejs and am using require.js to load each dependent backbone widget before firing up my app and putting everything in a custom namespace, in this case “Foo”. I’d like to have Jasmine load up this loader file and pick up all the dependent javascripts (located in /public/js of my main app), however, I’m getting all 404’s as Jasmine doesn’t know about the /public/js directory on port 8888. How can I get jasmine to load these javascripts?
Foo = {};
jQuery(function(){
var include = ['/js/widget.js','/js/delta_widget.js','/js/inbox.js','/js/time_widget.js','/js/high_stock_widget.js','/js/daily_summary_widget.js'];
require(include,function(){
$.getScript('/js/app.js');
});
});
For each of the javascripts, I’m getting:
Failed to load resource: the server responded with a status of 404 (Not Found) http://0.0.0.0:8888/js/widget.js
It would seem that your Jasmine loader file / SpecRunner is in a different directory than your require.js loader (main.js by default). You will have to configure require.js to use a different base path by doing the following:
You have to configure the above “baseUrl” property to point to the proper URL/Path.
For example, if your Jasmine SpecRunner is located in:
base
– main.js
– js
— widget.js
— app.js
– Libs
— Jasmine
— SpecRunner.html
then you need to configure
Hope this helps.