【问题标题】:Adding fixtures to jasmine/ Setting up Jasmine-Jquery为 jasmine 添加固定装置/设置 Jasmine-Jquery
【发布时间】:2011-12-05 19:20:01
【问题描述】:

我正在尝试使用 jasmine-jquery 插件:https://github.com/velesin/jasmine-jquery。在文档中它说:

只需从下载页面下载 jasmine-jquery.js 并包含 它在你的 Jasmine 的测试运行器文件中(或将它添加到 jasmine.yml 文件中 如果您将 Ruby 与 jasmine-gem 一起使用)。记得也包括 作为 jasmine-jquery 的 jQuery 库依赖于它。

我正在尝试使用此插件在咖啡脚本中为我的茉莉花测试添加固定装置,用于咖啡脚本一页 HTML5 画布应用程序。我正在使用 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)

非常感谢任何见解,因为我花了几个小时试图让它正常工作。如果你知道一个不同的测试框架,它会更容易为一个受欢迎的咖啡脚本项目设置。谢谢!

【问题讨论】:

    标签: javascript tdd coffeescript jasmine jasmine-jquery


    【解决方案1】:

    您尝试使用的库假定您在 html 页面中使用 jasmine。它和 jquery 都不能与 jasmine-node 一起使用。

    jQuery 不能在 node 上运行,因为它需要浏览器的 DOM api。有一些libraries that mock the DOM for node 可能会满足您的需求。

    【讨论】:

      【解决方案2】:

      您引用的测试运行程序文件包含在 Jasmine 的独立版本 (SpecRunner.html) 中。它不是 Jasmine 节点的一部分。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-05-25
        • 1970-01-01
        • 1970-01-01
        • 2011-11-20
        • 1970-01-01
        • 1970-01-01
        • 2012-11-25
        • 2012-12-04
        相关资源
        最近更新 更多