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

Tre*_*opz 4 javascript cucumber protractor cucumberjs

所以我实现了一个 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);
    });
Run Code Online (Sandbox Code Playgroud)

我的小黄瓜步骤看起来像

Then If I click the row "Summary" then I should the following nested information
      | Tax       | 11.50
      | Gratuity  | 4.50
      | Total     | 26.59
Run Code Online (Sandbox Code Playgroud)

现在我只是想获取此表并将其打印出来以确保它以正确的格式返回,但我收到词法错误并且测试甚至无法开始。你如何在Javascript中实现这个?我似乎无法在网上找到 cucumberjs 的任何文档或示例,但是当然有几个针对 java/cucumber 的文档或示例。

另外,我知道词法错误与它期望这是一个场景大纲这一事实有关,并且我没有在表之前指定示例:。然而,这不应该是一个场景大纲。这应该是一个数据表..

Tre*_*opz 5

这个问题的答案其实与最初的问题相差并不远。我缺少额外的“|” 在桌子的右侧。

Then If I click the row "Summary" then I should the following nested information
      | Tax       | 11.50  |
      | Gratuity  | 4.50   |
      | Total     | 26.59  |
Run Code Online (Sandbox Code Playgroud)

此外,请确保 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);
    }); 
Run Code Online (Sandbox Code Playgroud)

与我看到的 cucumber / java 示例相比,这非常简单。Cucumberjs 确实需要改进他们的文档..