Search code examples
javascriptunit-testingdojodoh

How to test non-dojo javascript code with doh?


doh is the dojo unit-testing framework. I am trying to use doh to test a non-dojo javascript code, but i am facing the problem that doh seems intrusive and oblige me to use dojo.provide() in the tested js file(and the corresponding dojo.require() in the test js file). I want the tested js file to be unmodified and dojo-agnostic. Is it possible ?


Solution

  • I have found the solution.

    • simple/MyModule.js
    • simple/tests/MyModuleTest.js

    In the test file, just use:

    dojo.provide("simple.tests.MyModuleTest");
    
    dojo.require("doh.runner");
    
    dojo.require("simple.MyModule",true);
    

    as the js file is find by its name without the dojo.provide() module check

    http://api.dojotoolkit.org/jsdoc/1.2/dojo.require