Javascript 如何使用grunt contrib jasmine制作jasmine ajax
我试图使用来模拟ajax请求,但jasmine似乎无法找到库(它说jasmine.ajax未定义) 我的grunt文件:Javascript 如何使用grunt contrib jasmine制作jasmine ajax,javascript,ajax,gruntjs,jasmine,grunt-contrib-jasmine,Javascript,Ajax,Gruntjs,Jasmine,Grunt Contrib Jasmine,我试图使用来模拟ajax请求,但jasmine似乎无法找到库(它说jasmine.ajax未定义) 我的grunt文件: jasmine: { test:{ src :[ '<%= watch.files %>'], options: { vendor: 'vendor/mock-ajax.js', specs
jasmine: {
test:{
src :[ '<%= watch.files %>'],
options: {
vendor: 'vendor/mock-ajax.js',
specs : ['specs/**/*spec.js'],
helpers : 'specs/helpers/*.js',
timeout : 10000
}
}
解决。。为了有同样问题的其他人的利益: 中的文件对我不起作用。 我通过npm安装了jasmine ajax,然后从Grunfile中引用了它的mock-ajax.js版本: 供应商:['node_modules/jasmine ajax/lib/mock ajax.js']
感谢jsoverson在检查路径时提供的提示()这是最近一个项目的设置,我刚刚用一个新的“git克隆”、“npm安装”、“grunt测试”进行了测试,它是现成的!希望有帮助:
jasmine: {
test:{
src :[
'<%= watch.files %>'
],
options: {
vendor: ['node_modules/jasmine-ajax/lib/mock-ajax.js',
'node_modules/jquery/dist/jquery.js',
'node_modules/jasmine-jquery/lib/jasmine-jquery.js',
'node_modules/handlebars/dist/handlebars.js',
],
specs : ['spec/helpers/*.js',
'spec/**/*spec.js'],
helpers : ['spec/helpers/*.js'],
timeout : 10000,
keepRunner: true
}
},
茉莉花:{
测试:{
src:[
''
],
选项:{
供应商:['node_modules/jasmine ajax/lib/mock ajax.js',
'node_modules/jquery/dist/jquery.js',
'node_modules/jasmine jquery/lib/jasmine jquery.js',
“node_modules/handlebar/dist/handlebar.js”,
],
规格:['spec/helpers/*.js',
“spec/***spec.js'],
助手:['spec/helpers/*.js'],
超时:10000,
基普朗纳:是的
}
},
我也在尝试同样的方法,但无法使其正常工作。我的GrunFile和node_模块位于同一父目录中。我是使用命令“npm install jasmin ajax”安装的并给出了与您提到的相同的供应商路径,但它给出了错误。请帮助!您好,感谢您的回复,但以下是我的代码,它不起作用。有什么想法吗?jasmine:{src:'dist/production.js',选项:{specs:'test/***.js',style:'style/***.css',供应商:[“node_modules/jasmine ajax/lib/mock ajax.js]”,模板:require('grunt-template-jasmine-requirejs')},您的确切错误消息是什么?检查您的_SpecRunner.html文件,该行应显示在脚本之前。检查节点是否在预期路径中包含该文件。提示:使用inspector工具,在浏览器中检查您的_SpecRunner.html,在项目根目录下运行本地web服务器。
jasmine: {
test:{
src :[
'<%= watch.files %>'
],
options: {
vendor: ['node_modules/jasmine-ajax/lib/mock-ajax.js',
'node_modules/jquery/dist/jquery.js',
'node_modules/jasmine-jquery/lib/jasmine-jquery.js',
'node_modules/handlebars/dist/handlebars.js',
],
specs : ['spec/helpers/*.js',
'spec/**/*spec.js'],
helpers : ['spec/helpers/*.js'],
timeout : 10000,
keepRunner: true
}
},