How to load a JS file that is not a module in dojo?

To begin with, I am javascript and dojo noob. However, I worked on writing some unit tests for my js code using the DOH structure. One thing I noticed is that the structure does not seem to be able to mock XHR requests. So I decided to use sinon for ridicule.

Here is my question: I cannot successfully load the sinon code into my dojo module. Here is what I tried:

define(["doh/runner", "tests/sinon-1.4.2"], function(doh, sinnon) { ... }); 

I have a test suite mapped to the correct directory and it can load other files from it. So, how do I load a sine?

+4
source share
1 answer

Download it through Generic Script Injection :

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

Working example in jsFiddle: http://jsfiddle.net/phusick/6tHtj/

+11
source

Source: https://habr.com/ru/post/1432882/


All Articles