I have tried this solution, it not works well.
Here is the example code from the link above:
require([
"doh/runner",
"http://sinonjs.org/releases/sinon-1.17.5.js"
], function(doh){
console.log(sinon);
});
Error message:
$ 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'
Besides this, I also try to require sinon.js directly.
sinon-1.17.5.js have been moved to the directory doh which is as same as runner.js, and renamed to sinon. (The directory )
require([
"doh/runner",
"doh/sinon"
], function(doh, sinon){
console.log(sinon);
});
There is no error message, but sinon is undefined:
$ 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
I am pretty sure that the second code loads sinon well. I verified that by modifying sinon.js directly. But I have no idea why sinon is not able to call.
Version
node.js - v6.2.2
dojo/doh - 1.10.0
sinon - 1.17.5
[UPDATED]
Because both
node.jsanddojohave require API, but they are different. This case is not working because it should use node.js's API to requiresinon.jsrather than dojo's API.Dojo provide the dojo/node module, it will call node.js module directly.
1. Install sinon by npm under same directory of dojo
2. Modify the code to use dojo/node
3. Back to original folder and run the test
Note, under dojo directory, it will contain npm_module/sinon