0

私はモカでうなり声を上げました。正常に動作していますが、テストが時々失敗する場合は、より詳細なレポートを取得したいと考えています. grunt detailedTest当然のことながら、毎回 grunt ファイルを変更する代わりに実行したいと思います。私はできると思った:

  • detailedTest という名前の新しい単調なタスクを作成します
  • そのテストを設定して、モカテスターの構成を変更します
  • 次に、テストを実行します

次のようになります。

  grunt.initConfig
    watch:
  ...
  mochaTest:
      files: [ 'test/calc/*.coffee', 'test/*.coffee']
    mochaTestConfig:
      options:
        reporter: 'nyan'
        timeout: 500

grunt.registerTask "spectest", ->
  grunt.config "mochaTestConfig:options:reporter", "spec"
  grunt.log.writeln('done with config: ' 
    + grunt.config "mochaTestConfig:options:reporter")
  grunt.task.run('mochaTest')

そして出力:

$ grunt spectest
Running "spectest" task
done with config: spec

Running "mochaTest:files" (mochaTest) task
 230 _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ ...etc 

くそー、それは仕様レポーターではありません。テスト前に構成を変更するにはどうすればよいですか? または、何らかの方法でコマンドラインから値を grunt に渡す必要がありますか?

4

1 に答える 1