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, 2020 in JQuery by kartik
• 37,510 points
4,553 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, 2020 by Niroj
• 82,880 points

Related Questions In JQuery

0 votes
1 answer

jQuery fix for "Uncaught TypeError: $ is not a function" error

We can fix this error by using jQuery() . ...READ MORE

answered Jun 1, 2022 in JQuery by Edureka
• 13,670 points
4,946 views
0 votes
1 answer

JavaScript/jQuery - "$ is not defined- $function()" error

You may experience the “jQuery is not ...READ MORE

answered Jun 6, 2022 in JQuery by Edureka
• 13,670 points
1,974 views
0 votes
1 answer

jQuery UI " $("#datepicker").datepicker is not a function"

The "$(...).datepicker is not a function" jQuery ...READ MORE

answered Jun 6, 2022 in JQuery by Edureka
• 13,670 points
10,403 views
0 votes
1 answer

$ is not a function - jQuery error

The typeerror: $ is not a function ...READ MORE

answered Jun 6, 2022 in JQuery by Edureka
• 13,670 points
851 views
0 votes
1 answer

Error:PHP Warning: POST Content-Length of 8978294 bytes exceeds the limit of 8388608 bytes in Unknown on line 0

Hello @kartik, 8388608 bytes is 8M, the default ...READ MORE

answered Sep 17, 2020 in PHP by Niroj
• 82,880 points
27,329 views
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, 2020 in PHP by Niroj
• 82,880 points
10,606 views
0 votes
1 answer

How to display HTML tags as plain text ?

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

answered Sep 17, 2020 in PHP by Niroj
• 82,880 points
2,460 views
+1 vote
2 answers

How to make asynchronous HTTP requests in PHP?

Hello @kartik, Use this code: function post_without_wait($url, $params) { ...READ MORE

answered Sep 17, 2020 in PHP by Niroj
• 82,880 points
2,279 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, 2020 in JQuery by Niroj
• 82,880 points
13,022 views
+1 vote
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, 2020 in JQuery by Niroj
• 82,880 points
1,624 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP