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

Javascript Cucumberjs数据表-如何将其转换为.raw(),javascript,protractor,cucumber,cucumberjs,Javascript,Protractor,Cucumber,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.l

所以我实现了一个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/cucumber的


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

这个问题的答案实际上与原始问题相差不远。我错过了桌子右侧的另一个“|”

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);
    }); 

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

您可以通过一些内置方法检查表的数据

(table.rows(),table.hashes(),table.rowsHash())

您可以在()找到上述方法的实现。

您得到的错误是什么?在我的表开始的行上出现词法错误。我在表中注意到的一件事是,您需要用分隔符ie“|”结束每一行。不确定这是否是复制粘贴错误。@Grasshopper噢,该死,就是这样!不,这是我自己的错:P它现在运行,但我得到了一个数据。raw不是一个函数。。如果我尝试data.hash,也会得到同样的结果。我不确定这一点,因为javascript中从未编码过,但在上面的代码中,您使用的是dataTable.raw()而不是data.raw()。Cucumberjs确实需要改进他们的文档。真的