2

分度器とcucumberjsでChai-as-promisedを使用しています。chai-as-promised ライブラリの .notify(callback) メソッドについて質問があります。

それぞれにいくつかのステップがある複数のシナリオを実行している場合。各ステップの最後に notify() を呼び出す必要がありますか?

そう

Scenario 1
  Step 1 Expect(promise).to.eventually.to.equal(true).and.notify(callback);
  Step 2 Expect(promise2).to.eventually.to.equal(true).and.notify(callback);
Scenario 2
  Step 3 Expect(promise3).to.eventually.to.equal(true).and.notify(callback);
  Step 4 Expect(promise4).to.eventually.to.equal(true).and.notify(callback);

私は常に、最後のステップで「and.notify(callback)」のみを使用する必要があります。

そう

Scenario 1
  Step 1 Expect(promise).to.eventually.to.equal(true);
  Step 2 Expect(promise2).to.eventually.to.equal(true).and.notify(callback);
Scenario 2
  Step 3 Expect(promise3).to.eventually.to.equal(true);
  Step 4 Expect(promise4).to.eventually.to.equal(true).and.notify(callback);

github ページにも同様の質問があります。 https://github.com/domenic/chai-as-promised/issues/65

4

1 に答える 1

1

Prior to CucumberJS v0.5.0, all Step Definitions needed to be defined with a callback argument that needed to be called once the step was finished executing.

In v0.5.0, they updated the library so that the callback argument was no longer necessary. From their CHANGELOG:

New features

  • Support promises from step definitions (Will Farrell)
  • Support synchronous step definitions (Julien Biezemans)

While the return value from chai-as-promised assertions aren't real promises, their interface is similar enough for CucumberJS to treat them like promises. So, to answer your question:

  • Prior to CucumberJS v0.5.0, you have to call notify() at the end of each step.
  • After CucumberJS v0.5.0, you do not have to call notify() at the end of any step.
于 2016-01-27T00:19:27.030 に答える