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);
  });
});
                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')
        }
      }
    },
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With