2015-04-04 87 views
1

與新鮮mean.io開始應用即mean.io單元測試不運行

mean init newApp 
cd newApp 
npm install [1] 
bower install 

[1] npm install --dev原因NPM永遠運行,並最終失敗,內存不足的錯誤,所以我跑npm install隨後單獨npm install devPackage用於devDependencies

列出的每個包gulp env:test mochaTest輸出然後

Invoking gulp - development 
[10:12:54] Using gulpfile ~/projects/kueDemo/gulpfile.js 
[10:12:54] Starting 'env:test'... 
[10:12:54] Finished 'env:test' after 56 μs 
[10:12:54] Starting 'loadTestSchema'... 
[10:12:54] Finished 'loadTestSchema' after 487 ms 
[10:12:54] Starting 'mochaTest'... 


    0 passing (0ms) 

[10:12:54] Finished 'mochaTest' after 48 ms 

沒有任何測試失敗,並且肯定有很多測試在文章包中運行,所以我不明白他們爲什麼沒有被拿起。

:我不得不CTRL-C停止吞任務並返回到提示

本身運行良好開箱即用的應用程序。如果我運行gulp test - 卡摩測試運行良好 - 摩卡測試仍然被忽略。

系統:

  • 節點v0.12.2
  • NPM v2.7.4
  • meanio v0.9.26

回答

4

好了,經過一番調試,我發現,這是在一個錯誤mean.io來源。

gulp/test.js以下行應該改變:

線20: 要求(」 ../ node_modules/meanio/LIB/core_modules /模塊/ util的 ')預加載(' ../ P的

require('../node_modules/meanio/lib/core_modules/module/util').preload('./packages/**/server', 'model'); 

同樣第24行:

return gulp.src('../packages/**/server/tests/*.js', {read: false}) 

return gulp.src('./packages/**/server/tests/*.js', {read: false}) 

node_modules/meanio/lib/core_modules/module/util預載功能現在會失敗,但你可以通過在walk功能修補2條真實路徑線解決這個問題:在此基礎上

// recursively walk modules path and callback for each file 
function walk(wpath, type, excludeDir, callback) { 
    // regex - any chars, then dash type, 's' is optional, with .js or .coffee extension, case-insensitive 
    // e.g. articles-MODEL.js or mypackage-routes.coffee 
    var rgx = new RegExp('(.*)-' + type + '(s?).(js|coffee)$', 'i'); 
    if (!fs.existsSync(wpath)) return; 
    fs.readdirSync(wpath).forEach(function(file) { 
    var newPath = path.join(wpath, file); 
    var stat = fs.statSync(newPath); 
    if (stat.isFile() && (rgx.test(file) || (baseRgx.test(file)) && ~newPath.indexOf(type))) { 
     var realPath = fs.realpathSync(newPath); 
     callback(realPath); 
    } else if (stat.isDirectory() && file !== excludeDir && ~newPath.indexOf(type)) { 
     walk(newPath, type, excludeDir, callback); 
    } 
    }); 
} 
+0

創建引入請求:https://開頭github.com/linnovate/meanio/pull/71 https://github.com/linnovate/mean/pull/1321 – Chris 2015-08-27 15:46:11