So I have implemented a Cucumberjs data table, however I do not think I have done it right.. Here what I have
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);
});
And my Gherkin step looks like
Then If I click the row "Summary" then I should the following nested information
| Tax | 11.50
| Gratuity | 4.50
| Total | 26.59
right now I am just trying to get this table and print it out to make sure it comes back in the right format, but I get a lexing error and the test wont even start. How can you implement this in Javascript?? I cant seem to find any documentation or examples online for cucumberjs, but of course there are several for java/cucumber.
Also, I understand that the lexing error is related to the fact that it is expecting this to be a scenario outline, and that I did not specify Example: before the table. However, this is not supposed to be a scenario outline. This is supposed to be a data table..
The answer to this question is actually not very far off from the original question. I was missing the additional '|' on the right side of the table.
Then If I click the row "Summary" then I should the following nested information
| Tax | 11.50 |
| Gratuity | 4.50 |
| Total | 26.59 |
Additionally, ensure that the javascript step definition contains the parameters in order of use. So in this case, the same step definition used in the question is correct
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);
});
This was suprisingly easy compared to the examples I saw for cucumber / java. Cucumberjs really needs to improve their documentation..