Question

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.

Was it helpful?

Solution

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)

OTHER TIPS

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.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top