2016-11-29 15 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确实需要改进他们的文档..