2016-07-01 6 views
0

私はカスタム発電機の開発に取り組んでいます。私はサブジェネレータのテストをいくつか追加しようとしています。yeomanのテストヘルパーは、どこでサブジェネレータを探すのですか?

これを達成するためにyeoman's test helpersを使用する方法を理解できません。 I composeWith()を使用してサブジェネレータをメインジェネレータと一緒に実行できましたが、テストヘルパがそれを認識することができません。

また、テストファイルからジェネレータを実行したときと、(コマンドラインから)正常に実行したときとの間にいくつかの奇妙な不一致があります。アプリ/ index.jsで

注:正常に実行したときにこのコードは失敗し、私のテストから実行します。 composeWith機能をthis.composeWith('my-generator: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. 

私のテストファイル内

initializing: function() { 
    this.composeWith('sub-generator'); 
}, 

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. 

テストファイルに、私がインストールした他の発電機が見えないのはなぜですか?代わりに24基の発電機の、それは私が唯一のあなたが発生する可能性のあるエッジケースのほとんどを修正するパス自体を渡す

composeWith http://yeoman.io/authoring/composability.htmlを呼び出すとき2.

+0

パスを通過してみてください:http://yeoman.io/authoring/composability.html settings.local –

+0

'.withGenerators([.. ../sub-generator/index.js '])私はpath.join()とpath.resolve()を使ってパスにバリエーションを渡してみましたが効果はありません。 – Deimyts

答えて

0

あなたはsettings.localを渡す必要があることを私に伝えます。

+0

それはそれを固定しました、ありがとう!私は 'settings.local'がテストのためになぜ必要なのか不思議ですが、' yo my-generator'を使ってジェネレータを実行しているのではないのです。 – Deimyts

関連する問題