mean.io单元测试不运行

时间:2015-04-04 08:24:21

标签: gulp mocha mean.io

从一个新的mean.io应用程序开始,即

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

[1] npm install --dev导致npm永远运行并最终因内存不足而失败,因此我为{{1}中列出的每个包运行npm install,然后单独npm install devPackage }}

devDependencies的输出是

gulp env:test mochaTest

任何测试都没有失败,并且在文章包中肯定会有大量的测试,所以我不明白他们为什么没有被选中。

注意:我必须按CTRL-C来停止gulp任务并返回提示

应用程序本身开箱即用。如果我运行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 ,则Karma测试运行正常 - 摩卡测试仍然被忽略。

系统:

  • node v0.12.2
  • npm v2.7.4
  • meanio v0.9.26

1 个答案:

答案 0 :(得分:4)

好的,经过一些调试后我发现这是mean.io源代码中的一个错误。

gulp/test.js中,以下行应该更改:

第20行:     要求(' ../ node_modules / meanio / LIB / core_modules /模块/ util的&#39)。预加载(' ../ P

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

同样第2​​4行:

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条realPath行来解决此问题:

// 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);
    }
  });
}