我有一个关于在 Grunt 中使用 jasmine 的问题.我一直收到错误,
I have a question about using jasmine with Grunt. I keep getting an error,
ReferenceError:找不到变量:需要在
每当我运行我的茉莉花测试时.这是我的 Gruntfile.js 的茉莉花条目:
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/*'
}
}
},
我可以在没有 require 的情况下运行虚拟测试,但是当我在测试中包含 require 时,就像这样,我得到了 require 错误.
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);
});
});
我也遇到了同样的问题.只需安装此节点包并将这一行添加到您的 Gruntfile 中,并且 require 应该会再次开始工作.
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-requirejsp>
jasmine: {
js: {
src: jsFiles,
options: {
specs: 'tests/*_spec.js',
helpers: 'tests/helpers/*',
vendor: 'vendor/*',
template: require('grunt-template-jasmine-requirejs')
}
}
},
这篇关于ReferenceError:找不到变量:需要在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!