I am trying to configure Karma to use jasmine-jquery without success ...
In my karma.conf.js file I have configured the framework:
frameworks: ['jasmine'],
and have loaded the required dependencies:
files: [
'../bower_components/jquery/dist/jquery.js',
'../bower_components/jasmine-jquery/lib/jasmine-jquery.js',
...
But when I run my test using grunt test, I have the following:
TypeError: undefined is not a function
at null.<anonymous> (/home/sofarell/workspace/myapp/bower_components/jasmine-jquery/lib/jasmine-jquery.js:352:13)
Looking at the source code of jasmine-jquery.js, it looks like it's not finding the jasmine reference probably because jasmine-jquery is being loaded before jasmine:
351. beforeEach(function () {
352. jasmine.addMatchers({
353. toHaveClass: function () {
Anyone else has faced this problem? Is there a way to solve that?
I just worked through this myself, turns out my karma-jasmine version was too old (~0.1.5
). Bumped it to ~0.2.0
in packages.json, did an npm install
, which installed 0.2.2
, and it worked. This github issue from the jasmine-jquery repo was the key.
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