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
• 11,890 points
83 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
• 23,950 points

Related Questions In JQuery

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
• 23,950 points
89 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
• 23,950 points
211 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
• 23,950 points
23 views
0 votes
1 answer

How to check if button is disabled in jQuery Mobile?

Hello, you can try $("#deliveryNext").is(":disabled") The following code works for ...READ MORE

answered May 29 in JQuery by Niroj
• 23,950 points
25 views
0 votes
1 answer

What is jQuery?

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

answered Feb 14 in JQuery by kartik
• 11,890 points
47 views
0 votes
1 answer

What is Laravel framework? Why one should use Laravel?

Laravel is a PHP web-framework; it utilized ...READ MORE

answered Mar 17 in Laravel by Niroj
• 23,950 points
71 views
0 votes
1 answer

How to download and install Lavavel framework?

Hey @kartik, First you must have xampp install ...READ MORE

answered Mar 17 in Laravel by Niroj
• 23,950 points
67 views
0 votes
1 answer

How can we get started with Laravel through Xampp?

Hii, First you need to start Apache and ...READ MORE

answered Mar 17 in Laravel by Niroj
• 23,950 points
32 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
• 23,950 points
41 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
• 23,950 points
18 views