對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