node.js - 自定义 Yeoman 生成器的 npm 测试失败

标签 node.js npm mocha.js yeoman yeoman-generator

我已经构建了一个自定义自耕农生成器。您可以在 https://github.com/abhishekoza/generator-ratchet 找到代码.

当我尝试“npm test”时,出现以下错误

  1 passing (454ms)
  1 failing


1) ratchet generator creates expected files:
     Uncaught Error: You don't seem to have a generator with the name mocha:app installed.
You can see available generators with npm search yeoman-generator and then install them with npm install [name].
To see the 1 registered generators run yo with the `--help` option.

npm ERR! Test failed.  See above for more details.
npm ERR! not ok code 0
The command "npm test" exited with 1.

对于完整的构建日志,网址为“s3.amazonaws.com/archive.travis-ci.org/jobs/26049613/log.txt”

我在 package.json 中添加了“generator-mocha”作为peerDependency。但是当我使用“npm install”时,它不会安装,所以我将其添加到“依赖项”下。 “generator-mocha”现已安装,但我仍然遇到上述错误。

为了构建这个自定义生成器,我引用了 https://github.com/yeoman/generator-gulp-webapp .

最佳答案

我查看了test.js in the generator-webapp并发现它们在 beforeEach 内的 createGenerator 调用中有一个额外的位。尝试将第 13 行左右的 test-creation.js 修改为:

this.app = helpers.createGenerator('ratchet:app', [
    '../../app', [
        helpers.createDummyGenerator(),
        'mocha:app'
    ]
]);

关于node.js - 自定义 Yeoman 生成器的 npm 测试失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23887487/

相关文章:

javascript - 使用 javascript 链接外部库时出现错误

javascript - 无法对 Angular 示例项目运行测试

node.js - Centos 7安装strongloop报错

node.js - 真正删除所有全局 npm 模块

node.js - 全局 NPM 包安装的简单 CircleCI 2.0 配置失败

javascript - Mocha 假阴性结果

javascript - 使用 ES6 导入模块和 pkg

node.js - 使用 nginx 作为指向 AWS alb 的反向代理

javascript - Should.js 在单个属性上链接多个断言

mongodb - 迁移到 meteor 1.7.0.4 : MongoDB : "updating the path ... would create a conflict at ..."