-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for in-step data tables #144
Comments
I'm not keen on the triple quote syntax. Instead I'm thinking of the following for single columns
library.given('a list of integers $list', function(list) {
// [1000, 2022, 9405]
}) and this for multiple columns
library.given('a table of data $table', function(table) {
// [{ left: 1, right: 3}, {left: 2, right: 4}]
}) Finally for multi line columns...
library.given('a table of data $table', function(table) {
/*
[
{ 'Henry V': 'Once more unto the\nbreech dear friends', 'Romeo and Juliet': 'What light from yonder\nwindow breaks'},
{ 'Henry V': 'And sheathed their\nswords for lack of argument', 'Romeo and Juliet': 'It is the East\nand Juliet is the sun'}
]
*/
}) |
Spaces characters they'll be taken into account as well?
Thanks |
Yes, indentation will be maintained |
thank |
Hi, Will you also support examples/where blocks "[ ]" in the in step tables? Feature: 100 Green Bottles
Scenario: Data Tables Scenario
Given a table of [z] data
left | right
[x] | 3
2 | [y]
Where:
x | y | z
2 | 98 | 3
10 | 90 | 7
100 | 0 | 8 library.given('a table of data', function(number, table, next) {
// First iteration [{ left: 2, right: 3}, {left: 2, right: 98}] and number = 3
// Second iteration [{ left: 10, right: 3}, {left: 2, right: 90}] and number = 7
// And so on..
}) Im busy evaluating yadda to possibly switch my cucumber.js tests over - im running into some restrictions and hopefully yadda can help :) Thank you. Regards, |
Good idea, shouldn't be too hard if I can get the rest working. I was looking into this issue a bit yesterday, and it might be harder than I first thought. The Yadda interpreter takes a list of strings rather than a richer object. I found out yesterday that changing this can break Moonraker. Plan B is to implement dictionary converters, which is something I've wanted for a long time, but quite tricky. With this in place the feature parser would parse multiline steps (with example table support as normal) into a single string containing \n characters. The dictionary converter would parse the single string into a list, table etc. When you came to implement the step you would have to do something like... dictionary.define('table', /(.+)/, tableConverter)
library.given('A table of data: $table', function(table, next) {
/*
[
{ 'Henry V': 'Once\n breech', 'Romeo and Juliet': ' What\nwindow'},
{ 'Henry V': ' And\nswords', 'Romeo and Juliet': 'It\n and'}
]
*/
} |
Looks great! |
Dictionary converters are in, but it's going to take a little longer to get the multiline steps. |
Multiline steps are available in 0.15.0. Just need to write the converters to parse the above. |
Awesome! Thanks a lot. |
I've released Yadda 0.15.2 which includes multline steps with list and single line data tables. Multiline tables i.e.
are going to be a bit harder. |
@cressie176 thx for al the work on this! Will tables work nice with with examples/where blocks in them? |
The example you posted above already works. |
👍 |
This helped me a lot: https://github.com/acuminous/yadda/blob/master/examples/data-tables/library.js Though I don't fully understand what's going on there. :( |
I get that there is support for Where|Example tables, where the scenario is executed for each row.
I'm looking for the support of datatables such that:
Given a list of integers:
| integers |
| 19 |
| 3 |
| 56 |
.given("a list of integers:", function( datatable ) { } );
where datatable follows the structure proposed by:
https://github.com/cucumber/cucumber-tck
specifically:
https://github.com/cucumber/cucumber-tck/blob/master/data_tables.feature
Thanks!
-jamie
The text was updated successfully, but these errors were encountered: