4

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 ?

3 Answers3

2

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

  • This seems to include the file, but registers it as "not-a-module". Any attempt to call a function in the file results in "function is not defined". How did you call the javascript function you wanted to test? – Daniel Alexiuc Jun 05 '12 at 01:40
0

I think DOH does have a dependency on the Dojo loader (only). Have you tried just defining the object which would normally be in the dojo.provide? You might get away with that. Instead of doing

dojo.provide("mytests.mymodule")

try

mytests.mymodule={};
peller
  • 4,435
  • 19
  • 21
0

You need to check this alternative of dojo DOH. It is Dojo Foundation Project developed by SitePen.

Community
  • 1
  • 1
Mithlesh Kumar
  • 748
  • 7
  • 16