Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jasmine lost jQuery with PhantomJS: ReferenceError: Can't find variable: $

I want to test my JS codes which uses jQuery by Jasmine in console with PhantomJS, but ReferenceError: Can't find variable: $

I can test the codes by Jasmine in browser normally.

Thank you for your help.

$ phantomjs examples/run-jasmine.js http://localhost:8888/
ReferenceError: Can't find variable: $

  http://localhost:8888/public/javascripts/PhotoTable.js:59
ReferenceError: Can't find variable: $

  http://localhost:8888/public/javascripts/PhotoTable2.js:129
ReferenceError: Can't find variable: $

  http://localhost:8888/public/javascripts/amenimomakezu.js:18
  http://localhost:8888/public/javascripts/amenimomakezu.js:20
ReferenceError: Can't find variable: _error

  http://localhost:8888/public/javascripts/p121106.js:29
  http://localhost:8888/public/javascripts/p121106.js:39
null
Data loaded [object Object]
Data loaded [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Data loaded [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object]
Winter in October
[object Object]
[object Object]
'waitFor()' finished in 200ms.

Animal
Passing 20 specs
like image 481
Feel Physics Avatar asked Nov 26 '12 02:11

Feel Physics


1 Answers

I ran into this problem also. I fixed it by changing my jasmine.yml to load jquery before it loads the rest of the javascript files:

src_files:
  - public/js/jquery.js
  - public/js/**/*.js
like image 90
yairgo Avatar answered Oct 01 '22 10:10

yairgo