我已经构建了一个自定义自耕农生成器。您可以在 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/