ReferenceError: Can#39;t find variable: require at(ReferenceError:找不到变量:需要在)
问题描述
我有一个关于在 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:找不到变量:需要在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:ReferenceError:找不到变量:需要在


基础教程推荐
- 在 JS 中获取客户端时区(不是 GMT 偏移量) 2022-01-01
- 响应更改 div 大小保持纵横比 2022-01-01
- 在for循环中使用setTimeout 2022-01-01
- 动态更新多个选择框 2022-01-01
- Karma-Jasmine:如何正确监视 Modal? 2022-01-01
- 有没有办法使用OpenLayers更改OpenStreetMap中某些要素 2022-09-06
- 当用户滚动离开时如何暂停 youtube 嵌入 2022-01-01
- 我什么时候应该在导入时使用方括号 2022-01-01
- 悬停时滑动输入并停留几秒钟 2022-01-01
- 角度Apollo设置WatchQuery结果为可用变量 2022-01-01