我有一个关于在 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模板网!
在 javascript 认为文档“准备好"之前,如何让How can I get my jasmine tests fixtures to load before the javascript considers the document to be quot;readyquot;?(在 javascript 认为文档“准备好
jasmine 运行和等待实际上是做什么的?What do jasmine runs and waitsFor actually do?(jasmine 运行和等待实际上是做什么的?)
如何提供模拟文件来更改 <input type='filHow to provide mock files to change event of lt;input type=#39;file#39;gt; for unit testing(如何提供模拟文件来更改 lt;input type=filegt; 的事
如何使用 Jasmine 对链式方法进行单元测试How to unit test a chained method using Jasmine(如何使用 Jasmine 对链式方法进行单元测试)
如何将 $rootScope 注入 AngularJS 单元测试?How do I inject $rootScope into an AngularJS unit test?(如何将 $rootScope 注入 AngularJS 单元测试?)
Jasmine - 如何监视函数中的函数调用?Jasmine - How to spy on a function call within a function?(Jasmine - 如何监视函数中的函数调用?)