对this question的回答不能回答我的问题。在实习生的项目目录之外加载依赖项
我想加载从我的项目根外使用实习生作为我的测试框架的依赖项。我目前有以下目录结构的工作:
www/
project1/
app/
lib/
project2/
app/
lib/
intern-tests/
node_modules/
tests/
functional/
project1-tests/
project2-tests/
unit/
project1-tests/
project2-tests/
intern.js
Gruntfile.js
正如你可以看到,我正在intern-tests
自己的项目,并希望这个目录来存放所有我试验所有我的项目。我已经设置了我的Gruntfile来执行测试,使用grunt exec库将grunt projectName
命令转换为grunt test --project=projectName
。所有这些工作正常,但我的单元测试无法加载project1/
和project2/
目录中的依赖关系。
例如,这是我的单元测试之一:
define([
'intern!object',
'intern/chai!assert',
'jquery',
'../../../../project2/lib/js/var/document',
'../../../../project2/lib/js/exports/file/functions/resizeInput'
], function(registerSuite, assert, $, document, resizeInput) {
registerSuite({
name: 'functions',
resizeInput: function() {
var $input = $(document.createElement('input'));
resizeInput($input, 8, 20, 450, 200);
assert.equal($input.width(), 450);
}
});
});
和运行测试给了我以下错误:
SUITE ERROR
Error: Failed to load module ../project2/lib/js/var/document from
project2/lib/js/var/document.js (parent: tests/unit/project2/functions)
at HTMLScriptElement.handler <__intern\node_modules\dojo\loader.js:517:27>
我怎么能包括我的其他项目,这些外部文件?
你有没有考虑让那些其他项目的子模块实习生测试项目还是会让你的实习生项目太大? – Richard
@Richard一切都是结构化的,他们需要成为单独的项目(否则我只需将我的实习生Gruntfile移动到“www”目录)。 – jperezov