views:

103

answers:

0

Hi all:

I want to insert a function before the DOM or jQuery's document.ready loads in my JsTestDriver test file. I tried inserting it in the setUp function, but upon alerting the length of document.ready list in the first line of code, the document.ready has already been loaded. I have tried inserting tags to it, but JsTestDriver doesn't seem to like it as the test file is a js file, not a html file.

Therefore I'm currently looking at inserting it at a place similar to the header of an ordinary js file. But here is where I get stuck. Does anyone know the equivalent place where I can insert my function so it will load before document.ready and DOM?

Thanks.

Below is a sample of the test file for JsTestDriver, testFile.js:

TestFile = TestCase("TestFoo");

TestFile.prototype.setUp = function() {
    // this is optional
    // it claims to be similar to JUnit's setup method
    alert('size of document.ready: ' + $.readyList.length);
}

TestFile.prototype.testFoo = function() {
    // test code here.
    // executes the specific document.ready function
    $.readyList[1]();
    // assertions here...
};