3

I'm new to using karma and unit testing in general. I tried finding a solution by googling this problem, but I wasnt able to find anything useful , as my app/assets/components does not have any jquery fiels what so ever, nor do i have any bower_components. If it helps,I'm using ruby on rails with angular js together.

the errors:

Chrome 36.0.1985 (Mac OS X 10.9.4) ERROR
Uncaught Error: Bootstrap's JavaScript requires jQuery
at /Users/giowong/rails_project/doctible_pre_treatment/app/assets/javascripts/bootstrap.js:7

Chrome 36.0.1985 (Mac OS X 10.9.4) ERROR
Uncaught Error: Bootstrap's JavaScript requires jQuery
at /Users/giowong/rails_project/doctible_pre_treatment/app/assets/javascripts/bootstrap.min.js:6

Chrome 36.0.1985 (Mac OS X 10.9.4) ERROR
Uncaught ReferenceError: jQuery is not defined
at /Users/giowong/rails_project/doctible_pre_treatment/app/assets/javascripts/ng-grid.js:3591

Chrome 36.0.1985 (Mac OS X 10.9.4) ERROR
Uncaught ReferenceError: jQuery is not defined
at /Users/giowong/rails_project/doctible_pre_treatment/app/assets/javascripts/select2.js:39

my karma config file

 // Karma configuration
module.exports = function(config) {
config.set({
// base path, that will be used to resolve files and exclude
basePath: '/Users/giowong/rails_project/doctible_pre_treatment/',

// testing framework to use (jasmine/mocha/qunit/...)
frameworks: ['jasmine'],

// list of files / patterns to load in the browser
files: [
  'app/assets/components/angular/angular.js',
  'app/assets/components/angular-mocks/angular-mocks.js',
  'app/assets/javascripts/main.js',
  'app/assets/javascripts/**/**/*.js',
  'app/assets/javascripts/*.js',
  'spec/javascripts/*.js'
],

// list of files / patterns to exclude
exclude: ['app/assets/javascripts/angular-google-maps.min.js'



],

// web server port
port: 8080,

// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
logLevel: config.LOG_INFO,

// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,

// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers: ['Chrome'],


// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: true
});
};
Apprentice Programmer
  • 1,485
  • 4
  • 26
  • 39
  • yeah and how do i fix it? – Apprentice Programmer Aug 08 '14 at 20:54
  • in the files array add the jquery file – az7ar Aug 08 '14 at 20:54
  • i dont think i have one due to the me using rails that imports a gem. Could you link me the possible file to downlload and import? – Apprentice Programmer Aug 08 '14 at 21:00
  • 1
    download this(http://code.jquery.com/jquery-1.11.1.min.js) file and save it as jquery-1.11.1.min.js and add this files path in the files array – az7ar Aug 08 '14 at 21:02
  • thanks, now it works! But i'm getting errors as follow Error: [$injector:modulerr] Failed to instantiate module DoctiblePreTreatment due to: Error: [$injector:modulerr] Failed to instantiate module ngDialog due to: Error: [$injector:nomod] Module 'ngDialog' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument. how do i fix? – Apprentice Programmer Aug 08 '14 at 21:15
  • you also need to add the js file for ngDialog – Yaron Schwimmer Aug 20 '14 at 09:00

0 Answers0