自定义yeoman生成器的npmtesting失败

我已经build立了一个自定义的yeoman生成器。 你可以在https://github.com/abhishekoza/generator-ratchetfind代码。

当我尝试“npmtesting”,我得到以下错误

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. 

对于完整的构build日志,url是“s3.amazonaws.com/archive.travis-ci.org/jobs/26049613/log.txt”

我在package.json中添加了“generator-mocha”作为peerDependency。 但是当我使用“npm install”时,它不会安装,所以我将它添加到“dependency”下。 “发电机摩卡”现在安装,但我仍然得到以上错误。

为了构build这个自定义生成器,我提到了https://github.com/yeoman/generator-gulp-webapp 。

我查看了generator-webapp中的test.js ,发现它们在createGenerator中的createGenerator调用中还有一beforeEach 。 尝试修改你的test-creation.js ,在第13行左右:

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

即使这个问题已经解决,这个问题可能还有另一个原因: https : //github.com/yeoman/generator-generator/issues/46

包含生成器的文件夹必须以“generator-”开头。 例如,如果您的发电机被称为我的发电机,那么该文件夹应该被称为发电机我的发电机。 这有点尴尬,因为在运行npm链接之后,我可以通过运行“yo my-generator”来使用我的生成器,但是运行npmtesting失败(直到我重命名文件夹)。

希望将来能帮助别人…