2016-11-29 16 views
1

所以,我實現了一個Cucumberjs數據表,但我不認爲我這樣做是正確的。這裏我有什麼Cucumberjs數據表 - 如何把它交給.RAW()

this.And(/^If I click the row "([^"]*)" then I should the following nested information$/, function (rowName, data) { 
     resultPage.clickRow(rowName); 
     data = dataTable.raw(); 
     return console.log(data); 
    }); 

和我小黃瓜一步看起來像

Then If I click the row "Summary" then I should the following nested information 
     | Tax  | 11.50 
     | Gratuity | 4.50 
     | Total  | 26.59 

現在我只是想獲得此表並打印出來,以確保它回來以正確的格式,但我得到一個詞法錯誤和測試甚至不會開始。你怎麼能在Javascript中實現這個?我似乎無法在網上找到任何有關cucumberjs的文檔或示例,但當然有幾個適用於java/cucumber。

另外,我明白lexing錯誤與它期望這是一個場景大綱以及我沒有在表之前指定示例有關。但是,這不應該是一個場景大綱。這應該是一個數據表..

+0

你得到的錯誤是什麼? – Grasshopper

+0

我的表開始行的Lexing錯誤 – Tree55Topz

+1

我在表格中注意到的一件事是,您需要用分隔符(即'|')結束每行。不知道這是否是複製粘貼錯誤。 – Grasshopper

回答

0

這個問題的答案其實離原始問題並不遙遠。我錯過了額外的'|'在桌子的右邊。

Then If I click the row "Summary" then I should the following nested information 
     | Tax  | 11.50 | 
     | Gratuity | 4.50 | 
     | Total  | 26.59 | 

此外,請確保JavaScript步驟定義包含按使用順序的參數。所以在這種情況下,

this.And(/^If I click the row "([^"]*)" then I should the following nested information$/, function (rowName, data) { 
     resultPage.clickRow(rowName); 
     data = dataTable.raw(); 
     return console.log(data); 
    }); 

這是令人驚訝容易比較,我看到了黃瓜/ java的例子在提問中使用的相同步驟定義是正確的。 Cucumberjs確實需要改進他們的文檔..