Using doT.js with require.js - backbone.js

I'm using an authentication example from here https://github.com/alexanderscott/backbone-login and instead of using underscore templates I would like to use doT.js templates.
I've added the doT.js source to the lib directory and my config.js looks like this
if (typeof DEBUG === 'undefined') DEBUG = true;
require.config({
baseUrl: '/assets',
paths: {
//'jquery' : 'http://code.jquery.com/jquery-1.10.2.js',
'jquery' : 'assets/lib/jquery',
'underscore' : 'assets/lib/underscore', // load lodash instead of underscore (faster + bugfixes)
'backbone' : 'assets/lib/backbone',
'bootstrap' : 'assets/vendor/bootstrap/js/bootstrap',
'doT' : 'assets/lib/doT',
'text' : 'assets/lib/text',
'parsley' : 'assets/lib/parsley'
},
// non-AMD lib
shim: {
//'jquery' : { exports : '$' },
'underscore' : { exports : '_' },
'backbone' : { deps : ['underscore', 'jquery'], exports : 'Backbone' },
'bootstrap' : { deps : ['jquery'], exports : 'Bootstrap' },
'parsley' : { deps: ['jquery'] },
'doT' : { exports : 'doT'}
}
});
require(['main']); // Initialize the application with the main application file.
my app.js looks like this
define([
"jquery",
"underscore",
"backbone",
"doT",
"utils"
],
function($, _, Backbone, doT) {
var app = {
root : "/", // The root path to run the application through.
URL : "/", // Base application URL
API : "/api", // Base API URL (used by models & collections)
// Show alert classes and hide after specified timeout
showAlert: function(title, text, klass) {
$("#header-alert").removeClass("alert-error alert-warning alert-success alert-info");
$("#header-alert").addClass(klass);
$("#header-alert").html('<button class="close" data-dismiss="alert">×</button><strong>' + title + '</strong> ' + text);
$("#header-alert").show('fast');
setTimeout(function() {
$("#header-alert").hide();
}, 7000 );
}
};
$.ajaxSetup({ cache: false }); // force ajax call on all browsers
//alert(doT.template("what up {{=it.name}}"),{'name': 'John'});
// Global event aggregator
app.eventAggregator = _.extend({}, Backbone.Events);
return app;
});
and HeaderView.js looks like this
define([
"app",
"text!templates/header.html",
"utils",
"bootstrap"
], function(app, HeaderTpl){
var HeaderView = Backbone.View.extend({
template: doT.template(HeaderTpl), //_.template(HeaderTpl),
initialize: function () {
_.bindAll(this);
// Listen for session logged_in state changes and re-render
app.session.on("change:logged_in", this.onLoginStatusChange);
},
events: {
"click #logout-link" : "onLogoutClick",
"click #remove-account-link" : "onRemoveAccountClick"
},
onLoginStatusChange: function(evt){
this.render();
if(app.session.get("logged_in")) app.showAlert("Success!", "Logged in as "+app.session.user.get("username"), "alert-success");
else app.showAlert("See ya!", "Logged out successfully", "alert-success");
},
onLogoutClick: function(evt) {
evt.preventDefault();
app.session.logout({}); // No callbacks needed b/c of session event listening
},
onRemoveAccountClick: function(evt){
evt.preventDefault();
app.session.removeAccount({});
},
render: function () {
if(DEBUG) console.log("RENDER::", app.session.user.toJSON(), app.session.toJSON());
this.$el.html(this.template({
logged_in: app.session.get("logged_in"),
user: app.session.user.toJSON()
}));
return this;
},
});
return HeaderView;
});
when i load the page I get the error
Uncaught ReferenceError: doT is not defined
I can call the doT.template() function in the app.js file and I can see that doT.js is loaded in my network tab but when I try and use it in the HeaderView.js I keep getting the error. I am new to require.js so I'm sure I'm misunderstanding how it works.

Looking at the source of doT I see that it calls define by itself. So you do not need a shim configuration for it. Providing a shim for a module that calls define can confuse RequireJS.
Moreover, in the case at hand here, I see that if doT detects that it is an AMD environment (which RequireJS is), then it does not define itself in the global space as doT. So your HeaderView.js file will have to have doT among the required modules. Something like:
define([
"app",
"text!templates/header.html",
"doT",
"utils",
"bootstrap"
], function(app, HeaderTpl, doT){

Related

AngularAMD and RequireJS, sometimes not load AngularJS filter

I try implement lazy loading front-end app using requirejs, angularAMD and angular, but sometimes app not found 'getProfit' filter and I got:
Error: [$injector:unpr] http://errors.angularjs.org/1.4.2/$injector/unpr?p0=getProfitFilterProvider%20%3C-%20getProfitFilter
main.js
if(document.location.hostname == "localhost")var ghost = "http://localhost:8080/project/";
else var ghost = "/";
require.config({
baseUrl: ghost+"resources/web/app/",
paths: {
'angular' : '//ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min',
'angularAMD' : '//cdn.jsdelivr.net/angular.amd/0.2.0/angularAMD.min',
'boostrapMin' : ghost+'resources/web/js/bootstrap.min',
'jQuery' : 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min',
'boostrap-angular-ui' : 'https://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.14.3.min',
'howCtrl' : ghost+'resources/web/app/controllers/howCtrl',
'depositBoxCtrl': ghost+'resources/web/app/controllers/depositBoxCtrl',
'calendarCtrl' : ghost+'resources/web/app/controllers/calendarCtrl',
'labCtrl' : ghost+'resources/web/app/controllers/labCtrl',
'urlSer' : ghost+'resources/web/app/services/urlSer',
'userSer' : ghost+'resources/web/app/services/userSer',
'chartSer' : ghost+'resources/web/app/services/chartSer',
'dialogService': ghost+'resources/web/app/services/dialogsSer',
'paymentsSer' : ghost+'resources/web/app/services/paymentsSer',
'daterService' : ghost+'resources/web/app/services/dateSer',
'statsCounter' : ghost+'resources/web/app/services/statsCounter',
'directives' : ghost+'resources/web/app/directives/directives',
'filters' : ghost+'resources/web/app/filters/filters',
'oddsFilter' : ghost+'resources/web/app/filters/oddsFilter',
'n3-line-chart': ghost+'resources/web/js/bower_components/n3-line-chart/build/line-chart.min',
'd3' : 'http://d3js.org/d3.v3.min',
//'d3' : ghost+'/resources/web/js/bower_components/d3/d3.min',
'n3-pie-chart' : ghost+'resources/web/js/bower_components/n3-charts.pie-chart/dist/pie-chart.min',
'nvd3ChartDirectives' : ghost+'resources/web/js/bower_components/angularjs-nvd3-directives/dist/angularjs-nvd3-directives.min',
'nvd3' : ghost+'resources/web/js/bower_components/nvd3/nv.d3.min',
'jquery.sparkline': ghost+'resources/web/js/jquery.sparkline.min',
'matchesApp' : ghost+'resources/web/app/matchesApp',
'labApp' : ghost+'resources/web/app/labApp'
}
shim: {
'boostrapMin' : ['jQuery'],
'boostrap-angular-ui': ['angular','jQuery','boostrapMin'],
'n3-line-chart' : ['angular'],
'n3-pie-chart' : ['angular'],
'nvd3ChartDirectives' : ['angular'],
'jquery.sparkline' : ['jQuery'],
'angularAMD': ['angular'],
'nvd3' : ['d3'],
'howCtrl' : ['d3','nvd3'],
},
deps: ['indexApp']
});
indexApp.js:
define("app",['angularAMD','boostrap-angular-ui','n3-line-chart','n3-pie-chart','nvd3ChartDirectives'], function (angularAMD) {
'use strict';
console.log("webApp initilization...");
var webApp = angular.module('webApp',['ui.bootstrap','n3-line-chart','n3-pie-chart','nvd3ChartDirectives']);
webApp.config(function($httpProvider,$locationProvider) {
$httpProvider.defaults.headers.common["X-Requested-With"] = 'XMLHttpRequest';
$locationProvider.html5Mode({enabled:true,requireBase: false,rewriteLinks:false});
})
return angularAMD.bootstrap(webApp);
});
require(['app',"jquery.sparkline"], function(app) {
'use strict';
console.log("Load main app code ....", app);
// add getProfit filter too app
app.filter('getProfit', function () {
return function (pick) {
if(pick.wl)return Math.round((pick.bOdd-1) * 100) / 100;
return -1;
};
});
......
I've noticed, that error occurs before define filter because console print 'Load main app code' after error. But after refresh (sometime not one refresh) app start work normal. Also I want to mention, maybe it is important, getProfit filter I use on html <span>{{p | getProfit}}</span>.
Problem seem like occurs in your indexApp.js file. Because you use both define('app',[]) and require(['app']) in a same module without synchronization their loading order.
There will be 2 solutions:
1. Move all the content in require() block to define() block.
define("app",['angularAMD','boostrap-angular-ui','n3-line-chart','n3-pie-chart','nvd3ChartDirectives', 'jquery.sparkline'], function (angularAMD) {
'use strict';
console.log("webApp initilization...");
var webApp = angular.module('webApp',['ui.bootstrap','n3-line-chart','n3-pie-chart','nvd3ChartDirectives']);
webApp.config(function($httpProvider,$locationProvider) {
$httpProvider.defaults.headers.common["X-Requested-With"] = 'XMLHttpRequest';
$locationProvider.html5Mode({enabled:true,requireBase: false,rewriteLinks:false});
})
console.log("Load main app code ....", app);
// add getProfit filter too app
app.filter('getProfit', function () {
return function (pick) {
if(pick.wl)return Math.round((pick.bOdd-1) * 100) / 100;
return -1;
};
});
return angularAMD.bootstrap(webApp);
});
2. Move all the content in require() block to another file (module). Then using angularAMD.filter instead of app.filter
Assuming this file will be filter.js and in the same directory with indexApp.js
define(["angularAMD", "jquery.sparkline"], function(angularAMD) {
'use strict';
console.log("Load main app code ....");
// add getProfit filter too app
angularAMD.filter('getProfit', function () {
return function (pick) {
if(pick.wl)return Math.round((pick.bOdd-1) * 100) / 100;
return -1;
};
});
});
Then in your indexApp.js . Load the filter.js module.
define("app",['angularAMD', 'boostrap-angular-ui','n3-line-chart','n3-pie-chart','nvd3ChartDirectives', 'filter'], function (angularAMD) {

Where do I place global overrides in a modular Backbone.js site?

We use RequireJS to add modularity to our Backbone.js site. I found myself with the need to override the Backbone.Collection class to add an advance filtering routine.
My questions is, say I have the following 'override',
Backbone.Collection.prototype.advanceFilter = function() {
/* Filtering code here */
};
and our site structure looks like the following:
where, main.js sits at the top level and beneath it is app.js; Where would I add this override, such that I don't have to add a new module to our RequireJS definition for every class? More generally, where are overrides to Backbone usually recommended?
Create a file (say Overrides.js in modules folder)
define(function(require){
var app = require('app');
Backbone.Collection.prototype.advanceFilter = function() {
/* Filtering code here */
};
// other overrides can also be added here in this file like
_.extend(Backbone.View.prototype,{}, {
// adding functions or overriding something
})
});
Now, require this file in main.js like
require([
'backbone',
'App',
'modules/Overrides',
'globalize',
.
.
.
],
function ( Backbone, App, ..... ) {
});
There you go!
Say, I want to add some function to the view or override some function such as render, initialize, remove,... universally in the application. You could do something like this:
_.extend(Backbone.View.prototype,{}, {
remove: function() {
alert("View removed");
this.$el.remove();
this.stopListening();
return this;
}
});
One easy option if using requirejs, in your require config add an init statement. eg,
require.config({
shim: {
'backbone': {
deps: ['underscore', 'jquery'],
exports: 'Backbone',
init: function (_) {
Backbone.Collection.prototype.advanceFilter = function() {
/* Filtering code here */
};
}
}
}
});
Alternatively you can use a map config call to amp all backbone calls to your overridden backbone,
require.config({
map: {
'*': { 'backbone': 'backbone-custom' },
'backbone-custom': { 'backbone': 'backbone' }
}
});
// backbone-custom.js file:
define(['backbone'], function (Backbone) {
Backbone.Collection.prototype.advanceFilter = function() {
/* Filtering code here */
};
return Backbone;
});
Either case will load the override into the backbone object before it is used anywhere.

Nothing displayed on-screen and no errors, but JavaScript objects are populated

This is my first trial on backbone + marionette + require + handlebars. I will provide the full explanation on what I did, and I have no clue on why it doesn't work. I removed all possible JavaScript errors, and everything gets properly loaded. So, no errors in the console, but the page stays entirely blank.
What it represents is a simple header menu with buttons (an unordered list of buttons to be displayed in the header).
Index.php
<head>
<meta charset="UTF-8">
<title>Zwoop</title>
<link rel="stylesheet" type="text/css" href="http://www.zwoop.be/dev/css/layout.css">
</head>
<body>
<script id='zwoop_interface' type='text/template'>
<div id="headerRegion">
</div>
<div id="mainRegion"></div>
</script>
<script src="http://www.zwoop.be/dev/js/libs/require/require.js" data-main="js/main"></script>
</body>
main.js
Notes: I don't receive any JavaScript errors and the JS files are properly loaded (I checked this in the browser).
//Require.js
require.config({
baseUrl: 'js',
paths : {
jQuery : '//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min',
jQueryUI : '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min',
lodash : 'libs/lodash/lodash',
backbone : 'libs/backbone/backbone',
marionette : 'libs/marionette/marionette',
handlebars : 'libs/handlebars/handlebars-v1.1.2',
text : 'libs/require/text',
localstorage : 'libs/backbone/localstorage'
},
shim : {
backbone: {
deps : ['jQuery', 'lodash'],
exports : 'Backbone'
},
marionette: {
deps : ['backbone'],
exports : 'Marionette'
},
handlebars: {
exports: 'Handlebars'
}
}
});
require(["backbone","marionette", "views/main_menuView"], function (Backbone, Marionette, Main_menuView) {
var Zwoop = new Marionette.Application();
//Pass options if required
var options = {
};
//Initialize functions
Zwoop.on("initialize:before", function(options){
console.log("test");
});
Zwoop.addInitializer(function(options){
var Main_Layout = Marionette.Layout.extend({
template: "#zwoop_interface",
regions: {
headerRegion: "#headerRegion",
bodyRegion: "#bodyRegion"
}
});
var main_layout = new Main_Layout();
//Rendering the layout is required before you can show anything within the regions
main_layout.render();
main_layout.headerRegion.show(Main_menuView);
console.log("rendered"); //This console log works
});
Zwoop.vent.on("main_layout:rendered", function(){
//Initialize router
new ZwoopRouter();
Backbone.history.start();
console.log("router started"); //This one is not called; I don't know why
});
//Start the application
Zwoop.start(options);
return Zwoop;
});
3_ main_menuView.js
Notes: I console logged 'Main_MenuCollection.toJSON()' and the object is properly set.
define([
'jQuery',
'marionette',
'handlebars',
'text',
'text!templates/main_menu.html',
'models/main_menuModel'
], function ($, Marionette, Handlebars, Text, Main_menu_tpl, Main_MenuCollection) {
'use strict';
var Main_MenuView = Marionette.ItemView.extend({
initialize: function () {
_.bindAll(this, 'render');
this.render();
},
el: '#headerRegion',
template: Handlebars.compile(Main_menu_tpl),
events: {
'click .main_menu_item':'select_menu'
},
select_menu: function(){
console.log("clicked");
},
render: function () {
this.$el.html(this.template({
models: Main_MenuCollection.toJSON()
}));
return this;
}
});
var main_menuView = new Main_MenuView();
return main_menuView;
});
4_ main_menu.html
This is the template that I used:
<ul id="main-menu">
{{#each models}}
<li><a id="{{models.id}}" href="{{models.href}}" class='main_menu_item'">{{models.label}}</a></li>
{{/each}}
</ul>
4_ main_menuModel.js model + collection
Note: Also here, I console logged the collection before returning it, and it is properly set.
define([
'backbone'
], function(Backbone){
var Menu_ItemModel = Backbone.Model.extend({
initialize: function(){
},
//These are data that are related to the main menu
defaults: {
id: 'undefined',
href: 'undefined',
label: 'undefined'
}
});
var btn_bars = new Menu_ItemModel({id:'btn_bars', href: 'bars', label:'Bars'});
var btn_eat = new Menu_ItemModel({id:'btn_eat', href: 'places_to_eat', label:'Places to eat'});
var btn_events = new Menu_ItemModel({id:'btn_events', href: 'events', label:'Bars'});
var btn_touristic = new Menu_ItemModel({id:'btn_touristic', href: 'touristic', label:'Touristic places'});
var btn_hotels = new Menu_ItemModel({id:'btn_hotels', href: 'hotels', label:'Hotels'});
var btn_shops = new Menu_ItemModel({id:'btn_shops', href: 'shops', label:'Shops'});
var btn_companies = new Menu_ItemModel({id:'btn_companies', href: 'companies', label:'Companies'});
var Main_MenuCollection = Backbone.Collection.extend({
initialize: function(){
},
model: Menu_ItemModel
});
var main_menuCollection = new Main_MenuCollection();
main_menuCollection.add([
btn_bars,
btn_eat,
btn_events,
btn_touristic,
btn_hotels,
btn_shops,
btn_companies
]);
return main_menuCollection;
});
The first attempt, and I'm not quite experienced yet so I really don't see where to find the problem. Do you have any suggestions?
Your main_layout gets rendered, but never shown. This seems to be the main issue.
In addition, console.log("router started") might not get called, because although you define a listened for the "main_layout:rendered" event, I don't see it getting triggered anywhere.
Also, it seems you might be confused about layouts VS regions : regions remain "static" with the application, whereas layouts are removed and redisplayed as the user navigates through the app. So for example, you'd use a region to display the app's header menu, but you'd use a layout to display (e.g.) the user's homepage (so you can organize the various sub-views). In other words, you create application regions to segment areas in your application that will always be displayed (e.g. header, main content, footer), and then you can also use layouts (with declared regions) to organize views that require sub-views (e.g. a "user profile" page with a "last comments" region, a "contact info" region, etc.). they have the same name, but think of application regions as "areas" in the application, and layout regions as "parts of a big, ciomplex view".
Last but not least, you might want to consider using layouts like this https://github.com/davidsulc/marionette-gentle-introduction/blob/master/assets/js/apps/contacts/list/list_controller.js#L43 (from my Marionette book) : note that we use the lyout's "show" event listener to then display the sub-views. This means we don't need to call render manually, which is more in line with Marionette's conventions.

backbone extension file loads, some helpers work, one doesn't

I have a backbone-extend.js file that I load in the require define in app.js. It has a Backbone.View extender class defining a couple helper methods. Two of the methods work just fine in my views, one always errors with Uncaught TypeError: Object [object global] has no method 'gotoUrl'. Why would just this one method be not defined but the other two are working fine? Do you see any issue in this code...
// Filename: backbone-extend.js
define([
'jquery',
'underscore',
'backbone'
], function($, _, Backbone) {
var helpers = {
eventSyncError: function(model,response,options) {
console.log('Sync error='+response.statusText);
$('#server-message').css({'color':'red', 'font-weight':'bold'}).text(response.statusText);
},
gotoUrl: function(url,delay) {
var to = setTimeout(function() { Backbone.history.navigate(url, true); }, delay);
},
getFormData: function(form) {
var unindexed_array = form.serializeArray();
var indexed_array = {};
$.map(unindexed_array, function(n, i) {
indexed_array[n['name']] = n['value'];
});
return indexed_array;
}
}
_.extend(Backbone.View.prototype, helpers);
});
Here is the code in view that calls it...
eventSyncMemberSaved: function(model,response,options) {
console.log("Member saved!");
$('#server-message').css({'color':'green', 'font-weight':'bold'}).text("Member saved!");
this.gotoUrl('members',2000);
//setTimeout(function() { Backbone.history.navigate('members', true); }, 2000);
},
saveMember: function() {
var data = this.getFormData($('#member-form'));
this.member.save(data, { success: this.eventSyncMemberSaved });
},
Thanks in advance for your help. I'm stuck.
The context of this is different in the success callback.
It no longer points to the view as it points to the xhr object
So it throws an error as that method is not available on the xhr object
To resolve it you need to bind the context of this to the success handler so that it points to the right object.
So in the initialize of the view add this code
initialize: function() {
_.bindAll(this, 'eventSyncMemberSaved');
}

Busterjs+requirejs+backbone how to write tests?

I got little problem with combination busterjs+requirejs+backbone, structure of my project:
js-src
--lib //jquery, require, etc
--views
--models
-app.js //require config and start of app
js (compiled same structure as above)
test
-buster.js
-require-config.js
-test-test.js
require-config.js:
require.config({
baseUrl: 'js-src/',
paths: {
jquery: 'lib/jquery',
jplugins: 'lib/jquery.plugins',
underscore: 'lib/underscore',
backbone: 'lib/backbone'
},
shim: {
'backbone': {
deps: ['underscore', 'jplugins'],
exports: 'Backbone'
},
'jplugins': {
deps: ['jquery']
}
}
});
typical file exept off that in lib:
define(function (require) {
var $ = require('jquery'),
Backbone = require('backbone'),
otherElem = require('views/other'),
View = Backbone.View.extend({
el: '#el',
initialize: function () {
},
showLinks: function (value) {
},
render: function ) {
}
});
return View;
});
buster.js:
var config = module.exports;
config['browser-all'] = {
autoRun: false,
environment: 'browser',
rootPath: '../',
libs: [
'js-src/lib/require.js',
'test/require-config.js'
],
sources: [
'js-src/**/*.js'
],
tests: [
'test/*-test.js'
]
// extensions: [
// require('buster-amd')
// ]
};
test-test.js:
buster.spec.expose();
require(['views/View'], function (module) {
describe("An AMD module", function () {
it("should work", function () {
expect(true).toEqual(true);
});
});
});
When i run it using buster test i get:
Uncaught exception: ./js-src/lib/require.js:192 Error: Script error
http://requirejs.org/docs/errors.html#scripterror
TypeError: uncaughtException listener threw error: Cannot read property 'id' of undefined
at Object.uncaughtException (/usr/local/lib/node_modules/buster/node_modules/buster-test-cli/lib/runners/browser/progress-reporter.js:49:50)
at notifyListener (/usr/local/lib/node_modules/buster/node_modules/buster-core/lib/buster-event-emitter.js:37:31)
at Object.emit (/usr/local/lib/node_modules/buster/node_modules/buster-core/lib/buster-event-emitter.js:101:17)
at Object.emitCustom (/usr/local/lib/node_modules/buster/node_modules/buster-test-cli/lib/runners/browser/remote-runner.js:283:14)
at /usr/local/lib/node_modules/buster/node_modules/buster-test-cli/lib/runners/browser/remote-runner.js:89:16
at /usr/local/lib/node_modules/buster/node_modules/buster-test-cli/node_modules/buster-capture-server/lib/pubsub-client.js:79:47
at Object.trigger (/usr/local/lib/node_modules/buster/node_modules/buster-test-cli/node_modules/buster-capture-server/node_modules/faye/node/faye-node.js:383:19)
at Object.distributeMessage (/usr/local/lib/node_modules/buster/node_modules/buster-test-cli/node_modules/buster-capture-server/node_modules/faye/node/faye-node.js:666:30)
at Object._deliverMessage (/usr/local/lib/node_modules/buster/node_modules/buster-test-cli/node_modules/buster-capture-server/node_modules/faye/node/faye-node.js:1065:20)
at Object.<anonymous> (/usr/local/lib/node_modules/buster/node_modules/buster-test-cli/node_modules/buster-capture-server/node_modules/faye/node/faye-node.js:1004:12)
Firefox 16.0, Linux:
How to write proper test with that structure?
It will help if you run the browser tests and check the outputs in the console. The error messages therein are usually much more expressive. You should also remove the autoRun directive from the buster configuration and re-enable the "buster-amd" extension.
I'm new to Buster.js as of yesterday, but I'll add the following 4 part suggestion.
1.) Uncomment "extensions: [require('buster-amd')]" in your 'buster.js'
2.) Remove 'baseUrl' from your 'require.config'
3.) Explicitly set paths to your libs. For example "jplugins: 'lib/jquery.plugins'" would become "jplugins: 'js-src/lib/jquery.plugins'", this would also be needed for models, collections, views, and other files sitting on the 'js-src/' directory.
require.config({
paths: {
jquery: 'js-src/lib/jquery',
views: 'js-src/lib/views',
somerootfile: 'js-src/somerootfile'
4.) Change your test to be like this ...
describe('some test', function(run) {
require(['models/your_model'], function(YourModel) {
run(function() {
it('should load', function() {
var yourModel = new YourModel();
yourModel.set('cat', 'dog');
expect(YourModel.get('cat')).toEqual('dog');
});
});
});
});
The problem seems to be that the 'baseUrl' in 'require.config' confuse Buster.js and tell it to no long respect the 'rootPath' set in 'buster.js'.

Resources