bessdsv / karma-jasmine-jquery

Jasmine-jquery plugin for Jasmine in Karma
Other
18 stars 55 forks source link

jQuery is undefined #2

Closed stan-ros closed 9 years ago

stan-ros commented 10 years ago

During karma start I got.

Uncaught ReferenceError: jQuery is not defined
  at /var/www/pullr/node_modules/karma-jasmine-jquery/lib/setJqueryForJasminJqueryPlugin.js:1

So seems that is not enough for karma.conf.js

`frameworks: ['jasmine','jasmine-jquery'],`
fbrix commented 10 years ago

Can confirm this behavior. I had to copy jasmine-jquery.js and one other file manually to the lib-folder to get it working.

ninjasort commented 10 years ago

Getting the same error. These files don't exist in the package: node_modules/karma-jasmine-jquery/lib/jqueryForJasmineJqeryPlugin.js" does not match any file. node_modules/karma-jasmine-jquery/lib/jasmine-jquery.js" does not match any file.

bessdsv commented 9 years ago

What a systems do you have? windows or linux? How you run installation? npm install jasmine-jquery or npm install ? I had same problem when i run npm install with bower in dependencies and my install script not running. You can try install only jasmine-jquery and if it not will be installed write me.

fbrix commented 9 years ago

I use Mac OS X 10.9.4. I tried npm install and npm install jasmine-jquery. Both did not work.

zedd45 commented 9 years ago

hey guys, this looks really weird, but it appears Karma is loading them in reverse order. I had the same problem, and I fixed it by inverting the order:

(Coffee):

frameworks: [
            # this must come before jasmine... 
            "jasmine-jquery"
            "jasmine"
        ]
robertlevy commented 9 years ago

changing the order did not solve this for me

zedd45 commented 9 years ago

I also had to add jquery to "files":

files: [
   'path/to/jquery/local/'
]

Also, make sure you are using jasmine-jquery": "^2.0.0". (I'm using jasmine 2.0, so this wasn't an issue for me.)

kibin commented 9 years ago

Changing the order and updating karma-jasmine to 0.2.x solved issue for me. Had this issue after changing the order: https://github.com/karma-runner/karma-jasmine/issues/20

bessdsv commented 9 years ago

Yes that's right. The order is important since it affects the order in which the files will be included to karma. Right order - reverse as karma works on the principle of LIFO stack. And about the version is the same is true. This plugin will only work for version karma-jasmine 2 and above. If you want I can add the comment in the description of the plugin.

kibin commented 9 years ago

I think it would be great, because it will save some time for someone.

chazzlabs commented 9 years ago

I believe I've got my project configured according to the suggestions of the others in this thread, but I'm still seeing this error:

node_modules\karma-jasmine-jquery\lib/jqueryForJasmineJqeryPlugin.js" does not match any file.
node_modules\karma-jasmine-jquery\lib/jasmine-jquery.js" does not match any file.
...
ReferenceError: Can't find variable: jQuery

I've verified that those files do not exist in the karma-jasmine-jquery/lib directory, however the file

node_modules\karma-jasmine-jquery\lib\setJqueryForJasminJqueryPlugin.js

does exist.

I'm using the following plugins and versions:

karma-jasmine v0.2.0
karma-jasmine-jquery v0.1.0

And my karma.conf.js references the plugins in the correct order:

frameworks: ['jasmine-jquery', 'jasmine', 'requirejs', 'sinon']
zedd45 commented 9 years ago

Is this a runtime (browser) error for Karma, or is it halting before running tests? RJS may be attempting to pull your dependencies in async, and I've had difficulty with ajax and Karma. (Everything is served from /base/.) Do you pre-optimize your RJS build, or is require trying to suck everything down at run time?

bessdsv commented 9 years ago

okay. When I made this plugin, I would like to date versions of files jquery and jquery-jasmine pumped through Bower, immediately after installation, but it's not all work. On this, I will do this: I will put in the plug-in files by default, which are relevant at the moment. And still going to run the script from Bower. those who are lucky the original files are replaced with new ones, and who does not, it will remain those that were. But it will work.

ninjasort commented 9 years ago

Wouldn't it be better to just install jquery and jasmine-jquery with npm? Node packages are probably better for building a karma adapter anyway..

robertlevy commented 9 years ago

+1


From: Cameron J Roemailto:notifications@github.com Sent: ‎10/‎1/‎2014 11:08 AM To: bessdsv/karma-jasmine-jquerymailto:karma-jasmine-jquery@noreply.github.com Cc: Robert Levymailto:robertlevy@live.com Subject: Re: [karma-jasmine-jquery] jQuery is undefined (#2)

Wouldn't it be better to just install jquery and jasmine-jquery with npm. Node packages are probably better for building a karma adapter anyway..


Reply to this email directly or view it on GitHub: https://github.com/bessdsv/karma-jasmine-jquery/issues/2#issuecomment-57478928

bessdsv commented 9 years ago

and then what is the use of an adapter? if you will install all yourself?

husa commented 9 years ago

@bessdsv Since you've added jasmine-jquery to the repository, maybe you can also add jquery, and include it as well. Because, at the moment, it's not so clear that local jQuery should be included. Personally I thought it's bundled within a plugin.

bessdsv commented 9 years ago

@husa I added jquery in the file jqueryForJasmineJqueryPlugin.js. version 2.1.1.