Uncaught ReferenceError:Karma: jQuery is not defined

0 votes

I am running Karma on my yeoman based angularjs app.

I get the following error when running "grunt karma":

Chrome 28.0 (Mac) ERROR
    Uncaught ReferenceError: jQuery is not defined
    at myNgApp/admin/app/scripts/bootstrap.min.js:6
Chrome 28.0 (Mac): Executed 0 of 0 ERROR (0.206 secs / 0 secs)

When I launch the app on my browser via "grunt server", everything seems fine. There are no errors on the console either.

My index.html also imports jquery.min.js before any other JavaScript file. Any idea what is going on?

May 12 in JQuery by kartik
• 27,140 points
611 views

1 answer to this question.

0 votes

Hii @kartik,

You first have to load jQuery in the karma.conf.js then this is how your list should look:

// list of files / patterns to load in the browser
files: [
  'app/bower_components/jquery/jquery.js',
  'app/bower_components/angular/angular.js',
  'app/bower_components/moment/moment.js',
  'app/bower_components/underscore/underscore.js',
  'app/bower_components/angular-mocks/angular-mocks.js',
  'app/bower_components/angular-resource/angular-resource.js',
  'app/bower_components/angular-route/angular-route.js',
  'app/bower_components/angular-sanitize/angular-sanitize.js',
  'app/bower_components/ngInfiniteScroll/ng-infinite-scroll.js',
  'app/bower_components/parametrizedLocation/dist/parametrizedLocation.js',
  'app/bower_components/angular-cookies/angular-cookies.js',
  'app/bower_components/angular-translate/angular-translate.js',
  'app/bower_components/angular-translate-loader-static-files/angular-translate-loader-static-files.js',
  'app/bower_components/angular-translate-storage-cookie/angular-translate-storage-cookie.js',
  'app/bower_components/angular-translate-storage-local/angular-translate-storage-local.js',
  'app/scripts/*.js',
  'app/scripts/**/*.js',
  'test/mock/**/*.js',
  'test/spec/**/*.js'
],
answered May 12 by Niroj
• 58,500 points

Related Questions In JQuery

0 votes
1 answer

What is jQuery?

Hey, jQuery is a fast and concise JavaScript ...READ MORE

answered Feb 14 in JQuery by kartik
• 27,140 points
92 views
0 votes
1 answer

Uncaught TypeError: Cannot read property 'msie' of undefined - jQuery tools

Hello, Use the following script tag in your ...READ MORE

answered Apr 28 in JQuery by Niroj
• 58,500 points
1,125 views
0 votes
1 answer

Uncaught Error: Bootstrap's JavaScript requires jQuery

Hello @kartik, You have provided wrong order for ...READ MORE

answered Apr 28 in JQuery by Niroj
• 58,500 points
2,241 views
0 votes
1 answer

Error:jQuery scrollTop not working in Chrome but working in Firefox

Hello @kartik, If your CSS html element has the following overflow markup, scrollTop will ...READ MORE

answered May 29 in JQuery by Niroj
• 58,500 points
570 views
0 votes
1 answer
0 votes
1 answer

How to remove all special characters from a string?

Hello @kartik, This should do what you're looking ...READ MORE

answered Sep 17 in PHP by Niroj
• 58,500 points
24 views
0 votes
1 answer

How to display HTML tags as plain text ?

Hello @kartik, Replace < with &lt; and& ...READ MORE

answered Sep 17 in PHP by Niroj
• 58,500 points
15 views
0 votes
2 answers

How to make asynchronous HTTP requests in PHP?

file_get_contents will do what you want $output = ...READ MORE

answered 3 days ago in PHP by Rajiv
• 140 points
13 views
0 votes
1 answer

What is the equivalent of jQuery .hide() to set visibility: hidden

Hello Kartik, There isn't one built in but ...READ MORE

answered Apr 28 in JQuery by Niroj
• 58,500 points
369 views
0 votes
1 answer

How to check if a jQuery plugin is loaded?

Hello @kartik, for the plugins that doesn't use ...READ MORE

answered Apr 28 in JQuery by Niroj
• 58,500 points
94 views