我正在尝试使用 jasmine-jquery 插件:https://github.com/velesin/jasmine-jquery .在文档中它说:
Simply download jasmine-jquery.js from the downloads page and include it in your Jasmine's test runner file (or add it to jasmine.yml file if you're using Ruby with jasmine-gem). Remember to include also jQuery library as jasmine-jquery relies on it.
我正在尝试使用此插件为 coffeescript 单页 HTML5 Canvas 应用程序的 coffeescript 中的 jasmine 测试添加固定装置。我正在使用 jasmine 的 jasmine-node 版本使用 node.js 运行我的 jasmine 测试 我对上述说明的问题是我没有看到要编辑的 jasmine 测试运行器文件,因此我无法调用来自此插件的方法,例如我的规范中的 load_fixtures。
我当前的项目目录结构是
coffescript/shape.coffee
index.html (An html file I would ideally like to use for my tests)
javascript/shape.js (The outputted coffeescript)
spec/shape.spec.coffee
spec/jasmine-jquery-1.3.1.js (The plugin)
非常感谢任何见解,因为我花了几个小时试图让它正常工作。如果你知道一个不同的测试框架和固定装置,它会更容易为 coffeescript 项目设置,这也很受欢迎。谢谢!
最佳答案
您尝试使用的库假定您在 html 页面中使用 jasmine。它和 jquery 都不能与 jasmine-node 一起工作。
jQuery 不能在节点上工作,因为它需要浏览器的 DOM api。有一些libraries that mock the DOM for node这可能会给你你所需要的。
关于javascript - 向 jasmine 添加固定装置/设置 Jasmine-Jquery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7734979/