11

我想通过 PhantomJS 在控制台中使用 Jasmine 的 jQuery 测试我的 JS 代码,但是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
4

1 回答 1

4

我也遇到了这个问题。我通过在加载其余 javascript 文件之前更改我的 jasmine.yml 以加载 jquery 来修复它:

src_files:
  - 公共/js/jquery.js
  - 公共/js/**/*.js
于 2014-01-17T19:17:32.590 回答