我建立了一个自定义的yeoman生成器。您可以在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.
对于完整的构建日志,URL为“ s3.amazonaws.com/archive.travis-ci.org/jobs/26049613/log.txt”
我在package.json中将“ generator-mocha”添加为peerDependency。但是,当我使用“ npm install”时,它不会安装,因此我在“ dependency”下添加了它。现在已安装“ generator-mocha”,但仍然出现上述错误。
为了构建此定制生成器,我引用了https://github.com/yeoman/generator-gulp-webapp。
最佳答案
我查看了test.js
in the generator-webapp
,发现在createGenerator
中的beforeEach
调用中还有一个附加位。尝试将第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/