I am using AMD with require.js and Backbone and I would like to test my application using buster.js. I have made buster to load my files and to run my specs, the main issue is that wen I run my specs buster is loading the files with out an order and this makes that sometimes jQuery, Underscore or another dependecie to be missing and makes my test crash
This is my buster file:
var config = module.exports;
config["My test"] = {
rootPath: "..",
environment: "browser",
sources: [
"*.js",
"helpers/*.js",
"libs/*.js",
"app/models/*.js",
"app/collections/*.js",
"app/views/*.js",
],
tests: [
"test/specs/*-test.js"
],
libs: [
"libs/require.js",
"main.js"
],
extensions: [
require("buster-amd")
]
};
I try by adding my main.js file to the sources configuration but stil does the same thing.
This is how my main file looks like:
require.config({
//Shorcut alias
paths: {
jQuery: 'libs/jquery.loader',
Backbone: 'libs/backbone.loader',
Underscore: 'libs/lodash.min'
},
shim: {
'Backbone': {
deps: ['jQuery', 'Underscore'],
exports: 'Backbone'
}
},
waitSeconds: 15
});
require(['App'], function(App){
App.initialize();
});
I am using some alias for my libs. And at the end I am initializing with a script that start my router, which sometimes breakes because wen I run the spec sometimes a lib or a script is missing.
This is my spec that is trying to load a view in order to test it.
define(['app/views/someView'], function(someView){
buster.testCase("A view", {
"Exist": function(){
expect(typeof someView).toEqual("object");
}
});
});
My specs passes. But sometimes it throws me this errors and sometimes it does not
Uncaught exception: ./libs/bootstrap.js:22 Uncaught TypeError: undefined is not a function
Uncaught exception: ./libs/jquery.mobiscroll.datetime.js:351 Uncaught TypeError: Cannot read property 'presets' of undefined
Uncaught exception: ./app/views/someView.js:44 Uncaught TypeError: Object [object Object] has no method 'modal'
For the first and second error is because jQuery is missing