Open hmorey3 opened 2 years ago
Hi, In my PR: https://github.com/b-yond-infinite-network/jest-cucumber-fusion/pull/31/files You may see step definition:
Then(/^I want to sell (\d+) items if they in list$/, (nItems, table) => {
if (typeof nItems !== "string") return;
if (typeof table === "string") return;
let iNumber = Number(nItems);
table.forEach((row) => {
if (iNumber > 0 && onlineSales.listedItems.includes(row.Item)) {
onlineSales.sellItem(row.Item);
iNumber--;
}
});
});
And usage:
Then I want to sell <nSale> items if they in list
| Item |
| Sabaton. Great War |
| <SaleItemName> |
Then I have <NItems> items for sale
Examples:
| nSale | SaleItemName | NItems |
| 2 | Cucumber for dummies | 2 |
And it seems this test pass. I suppose that you are talking about this behavior.
If you want to pass Gherkin table in second parameter it shouldn't be 'string' as in your example:
result_CucumberInput: string
Ah yes, you're right about the string being the wrong type but I believe the issue is still there regardless.
The example you gave looks like what I want to be able to do though, although I wasn't using a scenario outline. Will your PR fix it in the case I'm not using a scenario outline?
I suppose yes here is an example from the same test scenario (it use the same step definition):
Scenario: Complex Scenario
This scenario is necessary to make sure that related steps are working without examples.
Given I have 0 items for sale
When I bought the following items:
| Item |
| Mist written by Stephen King |
| Metallica. ReLoad. |
| Sabaton. Great War |
Then I have 3 items for sale
Then I want to sell 2 items if they in list
| Item |
| Sabaton. Great War |
| Cucumber for dummies |
And by the way actually I faced with the same issue as you are but with scenario outline. I need to double check the solution after my PR will be merge I'm not 100% sure it will fix it )))
@j8kin any update on whether the PR you opened will fix the issue presented above? Thanks for your help.
@hmorey3, I'm not the owner. Just contribute the code. @bruno-morel should approve, merge and deploy new version into NPM.
let me look into the PR
sorry it took so long :(
Hi, I am able to successfully use capture groups in regex stepdefs and separately gherkin tables in a different step def, but I can not use both in the same step def. This is something that is available in jest-cucumber, and so it's something I think should be supported here.
When I try the step def below, only the first parameter is given a value.