ReferenceError:无法找到变量:require at [英] ReferenceError: Can't find variable: require at
问题描述
我有一个关于在Grunt中使用茉莉花的问题。我一直收到一个错误,
ReferenceError:无法找到变量:处的
每当我运行我的茉莉花测试。这是我的Gruntfile.js的jasmine条目:
jasmine:{
js:{
src :jsFiles,
options:{
specs:'tests / * _ spec.js',
helpers:'tests / helpers / *',
vendor:'vendor / *'
}
}
},
我可以运行一个虚拟测试没有要求就好了,但是当我在测试中包含require时,我会得到require错误。
var testD = require('../ src / events_to_actions');
函数(){
it(是虚拟测试,function(){
expect(true).toEqual(true);
});
});
我有同样的问题。只需安装此节点包并将此行添加到您的Gruntfile并且需求应该再次开始工作。
https://github.com/cloudchen/grunt -template-jasmine-requirejs
jasmine:{
js:{
src: jsFiles,
options:{
specs:'tests / * _ spec.js',
helpers:'tests / helpers / *',
vendor:'vendor / *',
template:require('grunt-template-jasmine-requirejs')
}
}
},
I have a question about using jasmine with Grunt. I keep getting an error,
ReferenceError: Can't find variable: require at
whenever I run my jasmine tests. Here is my jasmine entry for my Gruntfile.js :
jasmine: {
js: {
src: jsFiles,
options: {
specs: 'tests/*_spec.js',
helpers: 'tests/helpers/*',
vendor: 'vendor/*'
}
}
},
I can run a dummy test without a require just fine, but when I include a require in a test, like so, I get the require error.
var testD = require('../src/events_to_actions');
describe("events_to_actions", function() {
it("is dummy test", function() {
expect(true).toEqual(true);
});
});
I had the same problem. Just install this node package and add this line to your Gruntfile and require should start working again.
https://github.com/cloudchen/grunt-template-jasmine-requirejs
jasmine: {
js: {
src: jsFiles,
options: {
specs: 'tests/*_spec.js',
helpers: 'tests/helpers/*',
vendor: 'vendor/*',
template: require('grunt-template-jasmine-requirejs')
}
}
},
这篇关于ReferenceError:无法找到变量:require at的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!