Reputation: 168
I'm attempting to use jasmine-jquery in my unit tests to test BackboneJS Views but i'm getting the following error when I try to run the tests:
Running "jasmine:src" (jasmine) task
Testing jasmine specs via PhantomJS
TypeError: 'undefined' is not an object (evaluating 'jasmine.spiedEventsKey = function (selector, eventName) { return [$(selector).selector, eventName].toString() }') at
test/vendor/jasmine-jquery-master/lib/jasmine-jquery.js:40
test/vendor/jasmine-jquery-master/lib/jasmine-jquery.js:34
test/vendor/jasmine-jquery-master/lib/jasmine-jquery.js:838
I'm using grunt, phantomjs, grunt-contrib-jasmine task and grunt-template-jasmine-requirejs.
This is my grunt config
jasmine : {
src : 'lib/**/*.js',
options : {
vendor: [
'test/vendor/Sinon/sinon-1.14.1.js',
'test/vendor/jasmine-jquery-master/vendor/jquery/jquery.js',
'test/vendor/jasmine-jquery-master/lib/jasmine-jquery.js'
],
specs: 'test/spec/**/*.js',
helpers: 'test/helpers/**/*.js',
template: require('grunt-template-jasmine-requirejs'),
templateOptions: {
requireConfigFile: 'lib/js/main.js',
requireConfig: {
baseUrl: './lib/js/',
paths: {
'app': 'app',
'router': 'router',
'text': './text-master/text',
}
}
}
}
},
Have I set this up incorrectly or am I simply unable to run jasmine-jquery headlessly?
Thanks
Upvotes: 0
Views: 261
Reputation: 2668
I ran into the same issue. Fixed it by including frameworks in a different order in my karma.conf.js
file.
wrong:
frameworks: ['phantomjs-shim', 'jasmine', 'jasmine-jquery']
correct:
frameworks: ['phantomjs-shim', 'jasmine-jquery', 'jasmine']
Upvotes: 1