I’m using jQuery 1.5 and Q-Unit to do my testing.
The application I’m working on has a file that acts as an application runner, with a ready function and a few other things:
-Main.js-
...
var foo = new Object();
foo.bar = function () {
/* function I'd like to test */
}
foo.ready = function () {
/* sets up the app. I don't want this to run in my test! */
}
$(document).ready(function(){
foo.ready();
});
...
Running the ready() function creates a bunch of objects I don’t want floating around in my unit tests, but I still need to test foo.bar() and the other functions in Main.js. Can I override the ready() callback? Or is there a better solution in general? Thanks!
You can do this, after jQuery file is loaded, you can check if its Unit testing and then apply this
But just use it when testing.