2

I ma trying to load require modules in node to test with jasmine. Hers my spec runner

var coffee,
    isVerbose,
    jasmine,
    key,
    showColors,
    sys,
    i,
    len,
    jasmine = require('jasmine-node'),
    fs = require("fs"),
    sys = require('sys');

for (i = 0, len = jasmine.length; i < len; i++) {
    key = jasmine[i];
    global[key] = jasmine[key];
}

isVerbose = true;
showColors = true;
coffee = true;

process.argv.forEach(function(arg) {
    switch (arg) {
        case '--color':
            return showColors = true;
        case '--noColor':
            return showColors = false;
        case '--verbose':
            return isVerbose = true;
        case '--coffee':
            return coffee = true;
    }
});

function runSpecs(callback) {
    jasmine.executeSpecsInFolder(__dirname + '/spec', (function(runner, log) {
        if (runner.results().failedCount === 0) {
            callback(true);
        } else {
            callback(false);
        }
    }), isVerbose, showColors);
}
exports.runSpecs = runSpecs;

my module that I am trying to load looks like this:

define(function(){
  function something(){
     return 'blah'
  }
 return {
  something: something
 };
});

my spec looks like this for now:

var something = require('../../static/source/something.js');

I get an error "define is not defined" I already tried using sample from from require js documentation didn't seem to work.

var requirejs = require('requirejs');

requirejs.config({
    //Pass the top-level main.js/index.js require
    //function to requirejs so that node modules
    //are loaded relative to the top-level JS file.
    nodeRequire: require
 });
rigaman
  • 151
  • 2
  • 7

0 Answers0