Cucumberjs数据表 - 如何将其转换为.raw()

问题描述 投票:1回答:1

所以我已经实现了一个Cucumberjs数据表,但我不认为我做得对..这就是我所拥有的

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 /黄瓜。

另外,我理解lexing错误与它预期这是一个场景大纲这一事实有关,而且我没有在表之前指定Example:但是,这不应该是一个场景大纲。这应该是一个数据表..

javascript protractor cucumber cucumberjs
1个回答
1
投票

这个问题的答案实际上与原始问题相差不大。我错过了额外的'|'在桌子的右侧。

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中看到的例子相比,这非常容易。黄瓜Js真的需要改进他们的文档..

© www.soinside.com 2019 - 2024. All rights reserved.