yeoman test-helper 在哪里寻找子生成器?
Where does the yeoman test-helper look for sub-generators?
我正在开发自定义 yeoman 生成器,我正在尝试为子生成器添加一些测试。
我不知道如何使用 yeoman's test helpers 来完成此操作。
我 能够使用 composeWith()
到 运行 与主生成器一起使用的子生成器,但我无法让测试助手识别它。
此外,当我从我的测试文件中 运行 生成器时,我发现了一些奇怪的差异,而当我 运行 它正常时(从命令行)。
在app/index.js:
注意: 此代码在 运行 正常时以及在我的测试中 运行 时失败。如果我将 composeWith
函数更改为 this.composeWith('my-generator:sub-generator')
,它从命令行成功 运行,但在测试期间仍然失败。
initializing: function() {
this.composeWith('sub-generator');
},
在我的测试文件中:
before(function (done) {
helpers.run(roundhouse)
.withGenerators([
[helpers.createDummyGenerator(), '../sub-generator']
])
.inDir(testDir)
.withPrompts(prompts.default)
.withOptions({"skipInstall": true})
.on('end', done);
});
从命令行(运行使用生成器(yo my-generator
)时产生的错误:
You don't seem to have a generator with the name sub-generator installed.
You can see available generators with npm search yeoman-generator and then install them with npm install [name].
To see the 24 registered generators run yo with the `--help` option.
当 运行 来自我的测试时:
Uncaught Error: You don't seem to have a generator with the name sub-generator installed.
You can see available generators with npm search yeoman-generator and then install them with npm install [name].
To see the 2 registered generators run yo with the `--help` option.
为什么我的测试文件看不到我安装的其他生成器?它告诉我我只有 2 个,而不是 24 个生成器。
调用composeWith时需要传settings.local
http://yeoman.io/authoring/composability.html
传递路径本身将解决您可能遇到的大多数边缘情况。
我正在开发自定义 yeoman 生成器,我正在尝试为子生成器添加一些测试。
我不知道如何使用 yeoman's test helpers 来完成此操作。
我 能够使用 composeWith()
到 运行 与主生成器一起使用的子生成器,但我无法让测试助手识别它。
此外,当我从我的测试文件中 运行 生成器时,我发现了一些奇怪的差异,而当我 运行 它正常时(从命令行)。
在app/index.js:
注意: 此代码在 运行 正常时以及在我的测试中 运行 时失败。如果我将 composeWith
函数更改为 this.composeWith('my-generator:sub-generator')
,它从命令行成功 运行,但在测试期间仍然失败。
initializing: function() {
this.composeWith('sub-generator');
},
在我的测试文件中:
before(function (done) {
helpers.run(roundhouse)
.withGenerators([
[helpers.createDummyGenerator(), '../sub-generator']
])
.inDir(testDir)
.withPrompts(prompts.default)
.withOptions({"skipInstall": true})
.on('end', done);
});
从命令行(运行使用生成器(yo my-generator
)时产生的错误:
You don't seem to have a generator with the name sub-generator installed.
You can see available generators with npm search yeoman-generator and then install them with npm install [name].
To see the 24 registered generators run yo with the `--help` option.
当 运行 来自我的测试时:
Uncaught Error: You don't seem to have a generator with the name sub-generator installed.
You can see available generators with npm search yeoman-generator and then install them with npm install [name].
To see the 2 registered generators run yo with the `--help` option.
为什么我的测试文件看不到我安装的其他生成器?它告诉我我只有 2 个,而不是 24 个生成器。
调用composeWith时需要传settings.local
http://yeoman.io/authoring/composability.html
传递路径本身将解决您可能遇到的大多数边缘情况。