We are using Backbone in our developed application (written by a colleague) and I was tasked to add unit testing framework to verify the correctness of our application for continuous integration. After starting to look at other things, I am trying out qUnit as it seems simple. To start, I thought of creating a simple Backbone model in qUnit, but is having trouble. Hope someone can enlighten me. Here goes:
For organization and clarity of code, we have a convention of naming our Backbone models with prefix of App.Models. For example, we have App.Models.Target which extends Backbone.Model in Target.js under App/Models/ folder.
In qUnit, I have:
test( "Target is valid, Target edit should return true", function() {
var model = new App.Models.Target();
console.log(JSON.stringify(model));
ok(true);
});
which fails but shows minimal if no helpful message.
So, I tried playing around and renamed App.Models.Target to simply Target, and replaced App.Models.Target in my qUnit test again as Target and everything worked perfectly. I am very convinced that the error is caused by the prefix, but removing these prefix seems backwards to me (testing framework should be able to handle these things if you can run the code anyway, right?).
I think, (and I hope) there is a way to do this without renaming our Backbone entities to remove our prefixes. I just can't see one from the internet yet. All the examples seem so trivial.
Can someone give a tip/recommendation to solve my problem? Any help will be greatly appreciated!