grunt-contrib-jasmine ReferenceError: 找不到变量: jQuery.

grunt-contrib-jasmine ReferenceError: Can't find variable: jQuery

本文关键字:jQuery 变量 找不到 grunt-contrib-jasmine ReferenceError      更新时间:2023-09-26

这是我的Gruntfile茉莉花配置任务。我通过供应商选项添加了jquery和jasmine-jquery。

jasmine: {
        src: {
            src: '<%= paths.dist %>/**/*.js',
            options: {
                specs: '<%= paths.tests %>/specs/*Spec.js',
                helpers: '<%= paths.tests %>/helpers/*Helper.js',
                outfile: '<%= paths.tests %>/_SpecRunner.html'
            },
            vendor: [
                "<%= paths.bower %>/jquery/dist/jquery.js",
                "<%= paths.bower %>/jasmine-jquery/lib/jasmine-jquery.js"
            ]
        }
    },
运行咕噜

咕噜后出现错误。看起来咕噜咕噜的茉莉不包括任务设置的供应商。

Running "jasmine:src" (jasmine) task
Testing jasmine specs via PhantomJS
>> ReferenceError: Can't find variable: jQuery at
>> dist/script.js:97
 Core
   X should return element
     ReferenceError: Can't find variable: $ in file:///Users/jedrzejchalubek/Dropbox/Script/tests/specs/CoreSpec.js (line 6) (1)
     ReferenceError: Can't find variable: $ in file:///Users/jedrzejchalubek/Dropbox/Script/tests/specs/CoreSpec.js (line 10) (2)

,这是我的错。供应商需要在选项内。任务配置应如下所示:

jasmine: {
    src: {
        src: '<%= paths.dist %>/**/*.js',
        options: {
            specs: '<%= paths.tests %>/specs/*Spec.js',
            helpers: '<%= paths.tests %>/helpers/*Helper.js',
            outfile: '<%= paths.tests %>/_SpecRunner.html',
            vendor: [
                "<%= paths.bower %>/jquery/dist/jquery.js",
                "<%= paths.bower %>/jasmine-jquery/lib/jasmine-jquery.js"
            ]
        },
    }
}