1

これが私の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"
            ]
        }
    },

grunt を実行するとエラーが発生します。grunt-jasmine には、タスクに設定されたベンダーが含まれていないようです。

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)
4

1 に答える 1

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"
            ]
        },

    }
}
于 2015-01-12T16:52:57.040 に答える