ekj
ekj

Reputation: 1082

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

I'll start by saying that I am a javascript and dojo noob. However, I have been working on writing some unit tests for my js code, using the D.O.H framework. One thing I noticed is that the framework does not seem to have a way to mock XHR requests. So I decided to use sinon for the mocking.

Heres 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 the tests package mapped to the correct directory, and can load other files from there. So how do I go about loading sinon?

Upvotes: 5

Views: 10602

Answers (1)

phusick
phusick

Reputation: 7352

Load it via Generic Script Injection:

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

    console.log(doh);
    console.log(sinon);

});

​ A working example at jsFiddle: http://jsfiddle.net/phusick/6tHtj/

Upvotes: 12

Related Questions