开发者

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 tha开发者_StackOverflowt 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 ?


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


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={};


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜