Search code examples
javascripttestingcommand-linedojodoh

DOH command-line testing of JavaScript functions outside of the Dojo root


I'm trying to run DOH from dojo-1.3.2 to test simple Javascript functions from command-line. However, I can't seem to get anything to run and the net seems to be devoid of DOH command-line documentation.

Ideally the structure I would like is:

Tests reside: C:\myproject\tests\

Dojo reside: C:\dojo-1.3.2\util\doh

As of right now I've put a simple test in ..\doh\tests

I try running while in the ..\doh directory:

java -jar ..\shrinksafe\js.jar runner.js testModule=tests.module

Each time I get:

js: uncaught JavaScript runtime exception: ReferenceError: "window" is not defin ed. An exception occurred: Error: Could not load 'tests.module'; last tried 'tests/module.js' 0 tests to run in 0 groups

Is there something I should be doing that I have left out? I've also tried pointing to the dojo.js file using dojoUrl= but still the same error.

As far as I can see my tests do not use window anywhere. I have three files:

tests/module.js

dojo.provide("tests.module");
dojo.require("tests.functions.functions");

tests/functions/functions.js

dojo.provide("tests.functions.functions");
dojo.require("tests.demoFunctions");

doh.register("tests.functions.functions", [
    function test_alwaysTrue(){
        doh.assertTrue(tests.demoFunctions.alwaysTrue());
    }
]);

tests/demoFunctions.js

    dojo.provide("tests.demoFunctions");

tests.demoFunctions.alwaysTrue = function(){
    return true;
};

I've also tried restructuring the directory to have ../dojo-1.3.2/ contain the tests. Running the same command as above from command-prompt fails identically. Dir Structure:

/dojo-1.3.2

   /dojo
   /tests
   ...
   /util

      /shrinksafe
      ...
      /doh

Solution

  • Not sure where the 'window' is coming from, but I don't think doh ever worked properly with tests outside the Dojo directory. Does it work if you copy util/doh to be a peer of your tests directory?