Reputation: 4305
Im trying to get a testing environment for JavaScript set up but I am having some trouble with Mocha and requirejs. So far I have installed Mocha and that works as it should because I have tested it with the sample test from the documentation. The problem arises when I try and require some of the modules I want to test. At the top of my test.js file I have this:
var assert = require("assert"),
door = require( '../../assets/scripts/modules/door' );
But i get this error message in the console.
ReferenceError: define is not defined
Its referring to the first line of the door.js file that is.
define(['../utils/templating/hogan', '../models/ApiCaller', 'Backbone'], function (hogan, ApiCaller) {
I have also tried requiring requirejs like so...
var assert = require("assert"),
requirejs = require( '../../assets/scripts/require' ),
door = require( '../../assets/scripts/modules/door' );
As you have probably guessed im new to testing JavaScript and any explanation or solution would be great.
Thanks.
Upvotes: 3
Views: 9298
Reputation: 4284
See if this gist https://gist.github.com/michaelcox/3800736 is helpful for you.
Upvotes: 4