2017-12-29 23 views
0

私はBDDの使用cucmber.jsでいくつかの単体テストを書くことを練習しています。 私は 'And'ステートメントを使用しようとします。cucumber.jsそして関数ではありません

TypeError: Add is not a function 
    at ... // my file location 
npm ERR! code ELIFECYCLE 
npm ERR! errno 1 
npm ERR! [email protected] cucumber: `cucumber.js ./test/e2e/Features -r ./test/e2e/StepDefinition` 
npm ERR! Exit status 1 
npm ERR! 
npm ERR! Failed at the [email protected] cucumber script. 
npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 

npm ERR! A complete log of this run can be found in: 
npm ERR!  /Users/lab1321_mac_air/.npm/_logs/2018-01-04T08_15_28_568Z-debug.log 
:エラーがここに

TypeError: Add is not a function 

は私のコード

.feature

Feature: dataTable 
Scenario Outline: <a> + <b> + <c> = <answer> 
    Given I had number <a> 
    And I add another number <b> 
    When I add with <c> 
    Then I got answer <answer> 

Examples: 
|a|b|c|answer| 
|1|2|3|6| 
|10|15|25|50| 

.stepDefinition

defineSupportCode(function({Given,When,Then,And}){ 
    let ans = 0; 
    Given('I had number {int}', function(input){ 
    ans = input 
    }) 
    And('I add another number {int}',function(input){ 
    ans += input 
    }) 
    When('I add with {int}',function(input){ 
    ans += input 
    }) 
    Then('I got answer {int}', function(input){ 
    assert.equal(ans,input) 
    }) 
}) 

とエラーメッセージは以下のようなものであることを示しています

私は何か間違って書いたのだろうかと思います。ありがとう!

+0

(あなたの例では、私はあなたが「そして」の前に4つのスペースを使用していることを参照)の位置合わせしようとすると、ときに/次に/を考えると。 log(typeof And) '? – gurvinder372

+0

あなたが表示しているエラーは、 'Add is a function'です...タイトルには'それは関数ではありません '...明確にしてください –

答えて

0

あなたは `コンソールで何` definedSupportCode`のコールバックを入力すると

+0

'Add' in機能はうまく動作します(エラーメッセージは表示されません)。エラーは.stepDefinitionで発生します。 – JeffChen

関連する問題