【发布时间】:2013-04-29 21:18:26
【问题描述】:
我完全是 Jasmine 和 RequireJS 的菜鸟,因此不胜感激。
我们有以下目录结构
/assets
/libs <- populated by Jam
/scripts
/tests
我正在尝试设置 Jasmine + Grunt + RequireJS 来运行我的测试,但是当我运行我的 grunt 任务时,我不断收到以下错误 grunt jasmine 我已经查看了 RequireJS 网站上的错误但在我看来,一切都已到位。
Error: scripterror: Illegal path or script error: ['scripts/MyModule']
这是我在 gruntfile.js
中的 Jasmine 设置jasmine: {
src: 'assets/scripts/**/*.js',
options: {
specs: 'tests/*spec.js',
template: require('grunt-template-jasmine-requirejs'),
templateOptions: {
requireConfig: {
baseUrl: '/assets',
paths: {
'jquery': 'libs/jquery/dist/jquery'
}
}
}
}
这是一个简单的测试规范 :)
require(['scripts/MyModule'], function (myModule) {
'use strict';
describe('A suite', function() {
it('should pass this test', function() {
expect(myModule).not.toBe(null);
});
});
});
RequireJS 在我的项目中运行良好,这是我为此运行的设置...
<script>
var require =
{
baseUrl: '/assets'
};
</script>
<script src="/assets/libs/require.js"></script>
我哪里出错了,我能做些什么来解决它?
【问题讨论】: