views:

162

answers:

3

I'm using js-test-driver to test my Javascript code on several browsers:

TestCase("DropDownValueReplacerTestCase", {
    setUp:function() {
        console.log("BEGIN: setUp");
        /*:DOC += <form id="bob"></form> */

        console.log("END: setUp");
    },

    tearDown:function() {
        console.log("BEGIN: tearDown");

        console.log("END: tearDown");
    },

    testA:function() {
        console.log("Creating foo element.");

        /*:DOC += <form id="bob"></form> */

        var forms = document.getElementsByTagName('form');

        assertNotNull(forms);
        console.log("forms:" + forms.length);
        assertTrue(forms.length > 0);

        var bob = document.getElementById("bob");
        assertNotNull(bob); 
    }
});

The /*:DOC += */ statement is supposed to append html to the body tag, but apparently it doesn't work for some reason.

When I replace the :DOC syntax with something more verbose, such as:

    var form = document.createElement("form");
    document.body.appendChild(form);
    form.id = "bob";

the test works just fine.

Did they change something and not update the documentation? I checked the hello world example out of the trunk on SVN per the website's directions to test this out. There doesn't seem to be a version number or anything.

A: 

For one: I think you're after jstestdriver.console.log, which actually logs back to the shell.

Secondly, you create the same piece of DOM from both setUp and the test method. Try removing one of them.

In any case, copying the example verbatim works for me, I'm using 1.2. Which version did you first try with? Which browser(s) are you running in?

Also: The project isn't dead, check the mailing list. Not the most active project out there, but it's moving.

Christian
+1  A: 

It works on mine, are you using version 1.2, here?

I know they did not support it in earlier versions and maybe trunk is unstable (even though it does not look like its been modified for a while)

David Raznick
Seems kinda dumb to copy it out of the trunk anyway...I was just following the directions that I read.
leeand00
Yeah that was the problem. They need to keep that documentation up-to-date. hmm I wonder if I can do that?
leeand00
It seems like there are many comments on the wiki that have not been responded to. I imagine the googlers do some work internally then push it all back at once, without really checking whats there.
David Raznick
A: 

Re: logging, see the docs text about grabbing the window.console output. It's pretty rad.

olleolleolle