13

I have seen many other answers on this site but none of them worked for me.

The problem: I need to load jQuery with an URL, not with a local path; and I think I can't add thoose to "files" on karma.conf.js.

Everything seems to be fine, but when I try to use karma to test it, it returns: Uncaught ReferenceError: $ is not defined.

The order of the scripts is fine in the two .html we use.

dquijada
  • 1,697
  • 3
  • 14
  • 19

1 Answers1

30

Simple include the jQuery path in the karma.conf.js (as for Karma 0.12 at least):

module.exports = function(config) {
  config.set({

    files: [
      'https://code.jquery.com/jquery-1.11.2.min.js'
      ...
    ],

    ...
  });
};

I've tested it yesterday because I needed a similar thing for AngularJS.

MarcoL
  • 9,829
  • 3
  • 37
  • 50
  • 1
    AFAIK the format of the karma config file in the version 1.0 is stil the same as the one described in this answer: http://karma-runner.github.io/1.0/config/configuration-file.html – MarcoL Jan 03 '18 at 11:35