1

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.

leeand00
  • 25,510
  • 39
  • 140
  • 297
  • Additionally, why does this project look so dead? It seems like a good idea (except for display specific browser bugs...:( ) – leeand00 Jan 27 '10 at 20:32

3 Answers3

3

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
  • 17,907
  • 2
  • 35
  • 27
  • Seems kinda dumb to copy it out of the trunk anyway...I was just following the directions that I read. – leeand00 Jan 27 '10 at 21:11
  • Yeah that was the problem. They need to keep that documentation up-to-date. hmm I wonder if I can do that? – leeand00 Jan 27 '10 at 21:19
  • 1
    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 Jan 27 '10 at 21:30
2

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
  • 302
  • 2
  • 8
1

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

olleolleolle
  • 1,918
  • 16
  • 20