grunt-contrib-jasmine ReferenceError: Can't find variable: jQuery
grunt-contrib-jasmine ReferenceError: Can't find variable: jQuery
这是我的 Gruntfile jasmine 配置任务。我通过供应商选项添加了 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)
哦,是我的错。供应商需要在选项内。任务配置应如下所示:
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"
]
},
}
}
这是我的 Gruntfile jasmine 配置任务。我通过供应商选项添加了 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)
哦,是我的错。供应商需要在选项内。任务配置应如下所示:
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"
]
},
}
}