dojo 的 doh 没有与 sinon 合作

doh of dojo is not working with sinon

我试过 this 解决方案,但效果不佳。

下面是上面 link 中的示例代码:

require([
    "doh/runner",
    "http://sinonjs.org/releases/sinon-1.17.5.js"
], function(doh){
    console.log(sinon);
});

错误信息:

$ node ../../dojo/dojo.js load=doh test=tests/test_sinon_spy.js
Error: ENOENT: no such file or directory, open 'http://sinonjs.org/releases/sinon-1.17.5.js'

除此之外,我还尝试直接要求sinon.js。

sinon-1.17.5.js已移至与runner.js相同的目录doh,并重命名为sinon。 (目录)

require([
    "doh/runner",
    "doh/sinon"
], function(doh, sinon){
    console.log(sinon);
});

没有错误信息,但是 sinon 未定义:

$ node ../../dojo/dojo.js load=doh test=tests/test_sinon_spy.js
undefined
0 'tests to run in' 0 'groups'
------------------------------------------------------------
| TEST SUMMARY:
------------------------------------------------------------
         0 tests in 0 groups
         0 errors
         0 failures

我很确定第二个代码可以很好地加载 sinon。我通过直接修改 sinon.js 验证了这一点。但是不知道为什么sinon不能调用


版本

node.js - v6.2.2
dojo/doh - 1.10.0
sinon - 1.17.5

[更新]

因为node.jsdojo都有需要API,但又不一样。这种情况不起作用,因为它应该使用 node.js 的 API 来要求 sinon.js 而不是 dojo 的 API.

Dojo提供了dojo/node模块,它会直接调用node.js模块。

1.在dojo

同目录下通过npm安装sinon
$ cd ../../dojo
$ npm install sinon

2。修改代码使用dojo/node

# test_sinon_spy.js
require([
    "doh/runner",
    "dojo/node!sinon"
], function(doh, sinon){
    console.log(sinon);
})

3。返回原始文件夹并运行 测试

$ cd -
$ node ../../dojo/dojo.js load=doh test=tests/test_sinon_spy.js

注意,在dojo目录下,会包含npm_module/sinon