jquery - Jasmine 没有加载供应商选项

标签 jquery testing gruntjs jasmine bower

我正在尝试设置一个示例 Jasmine 应用程序,但似乎我在包含 jQuery 时犯了一个错误。 我的 Gruntfile 看起来像这样:

module.exports = function(grunt) {

    // Project configuration.
    grunt.initConfig({
        jasmine: {
            src: 'src/**/*.js',
            specs: 'spec/**/*.js',
            options: {
                vendor: 'bower_components/jquery/dist/jquery.js'
            }
        }
    });

    grunt.loadNpmTasks('grunt-jasmine-runner');


    // Default task.
    grunt.registerTask('default', 'jasmine');

};

我有一个规范文件,它在某处引用了 $,它将失败并显示以下消息:

ReferenceError: Can't find variable: $
    at http://127.0.0.1:8888/spec/PlayerSpec.js:14
    at http://127.0.0.1:8888/node_modules/grunt-jasmine-runner/jasmine/lib/jasmine-core/jasmine.js:1035
    at http://127.0.0.1:8888/node_modules/grunt-jasmine-runner/jasmine/lib/jasmine-core/jasmine.js:2034
    at http://127.0.0.1:8888/node_modules/grunt-jasmine-runner/jasmine/lib/jasmine-core/jasmine.js:2024

jquery.js 的路径肯定是正确的。如果我删除 $ 引用,规范就会通过。

最佳答案

你的问题的原因是 grunt-jasmine-runner 不支持 grunt 0.4+,并且它没有 vendor 选项.而是使用与 grunt 0.4+

一起工作的更新的 grunt-contrib-jasmine

关于jquery - Jasmine 没有加载供应商选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28987107/

相关文章:

javascript - PHP echo 与浏览器一起工作,而不是与 jQuery 一起工作

javascript - 单击时 Accordion 删除 Div

android - maven-android-plugin 和 Android 测试项目提供 INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES

node.js - 如何创建 tar 压缩的 npm 模块

javascript - 使用 jQuery 在父级 <div> 中选择 <divs>

html - 如何访问Primeng表的style属性

testing - 添加断言编码的 UI 测试

node.js - 我无法部署我的 platypi 演示应用程序

gruntjs - grunt 更新一项任务中的选项,以便后续任务可以使用它们

javascript - 如何在母版页的内容页中使用 jQuery 函数?