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:找不到变量:需要在


- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
- 如何向 ipc 渲染器发送添加回调 2022-01-01
- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01
- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01
- 从原点悬停时触发 translateY() 2022-01-01
- 在不使用循环的情况下查找数字数组中的一项 2022-01-01
- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 如何显示带有换行符的文本标签? 2022-01-01
- 如何调试 CSS/Javascript 悬停问题 2022-01-01