我想在PhantomJS的控制台中测试我的JS代码,它使用Jasmine的jQuery,
但是ReferenceError: Can't find variable: $
我可以通过浏览器中的Jasmine正常测试代码。
感谢您的帮助。
$ 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
答案 0 :(得分:4)
我也遇到了这个问题。我通过更改我的jasmine.yml来加载jquery,然后加载其余的javascript文件来修复它:
src_files: - public/js/jquery.js - public/js/**/*.js