Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReferenceError: Can't find variable: require at

I have a question about using jasmine with Grunt. I keep getting an error,

ReferenceError: Can't find variable: require at

whenever I run my jasmine tests. Here is my jasmine entry for my Gruntfile.js :

jasmine: {
      js: {
        src: jsFiles,
        options: {
          specs: 'tests/*_spec.js',
          helpers: 'tests/helpers/*',
          vendor: 'vendor/*'
        }
      }
    },

I can run a dummy test without a require just fine, but when I include a require in a test, like so, I get the require error.

var testD = require('../src/events_to_actions');

describe("events_to_actions", function() {
  it("is dummy test", function() {
    expect(true).toEqual(true);
  });
});
like image 232
worker1138 Avatar asked May 03 '14 20:05

worker1138


1 Answers

I had the same problem. Just install this node package and add this line to your Gruntfile and require should start working again.

https://github.com/cloudchen/grunt-template-jasmine-requirejs

jasmine: {
      js: {
        src: jsFiles,
        options: {
          specs: 'tests/*_spec.js',
          helpers: 'tests/helpers/*',
          vendor: 'vendor/*',
          template: require('grunt-template-jasmine-requirejs')
        }
      }
    },
like image 117
user3741597 Avatar answered Sep 30 '22 17:09

user3741597