2015-04-04 79 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