-
Notifications
You must be signed in to change notification settings - Fork 118
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
stringDocs causes autoBindSteps to map incorrectly #163
Comments
I created an example test to isolate the problem, and thanks to it, I saw that a repeated step caused my error. By changing the docString, the interface changed, and duplicates were no longer produced. That's why I related the problem to the docString. Mea culpa**, I'm so sorry.** That said, now that I see that the error is mine, I would like to propose an improvement; when a scenario is duplicated and we are using autoBinSteps, I propose to show an error indicating this situation, instead of the current behavior, the message that appears in the console is precisely the opposite, related to the lack of steps. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I've just tested, and autoBindSteps doesn't detect the duplication of steps, and the error message indicates a missing step, which can mislead the user. Step to reproduce the problem.
export const vendingMachineSteps: StepDefinitions = ({ given, and, when, then }) => {
let vendingMachine: VendingMachine;
given(/^the vending machine has "(.*)" in stock$/, (itemName: string) => {
vendingMachine = new VendingMachine();
vendingMachine.stockItem(itemName, 1);
});
/: steps duplicate
given(/^the vending machine has "(.*)" in stock$/, (itemName: string) => {
vendingMachine = new VendingMachine();
vendingMachine.stockItem(itemName, 1);
});
and('I have inserted the correct amount of money', () => {
vendingMachine.insertMoney(0.5);
});
when(/^I purchase "(.*)"$/, (itemName: string) => {
vendingMachine.dispenseItem(itemName);
});
then(/^my "(.*)" should be dispensed$/, (itemName: string) => {
const inventoryAmount = vendingMachine.items[itemName];
expect(inventoryAmount).toBe(0);
});
};
It might be interesting to see if they can put a more explicit error message. @bencompton I think we should keep this issue open and tag it bug. |
First of all, thanks to all of you for collaborating in the creation and maintenance of this great library.
I wanted to share with you a problem I'm experiencing with autoBindSteps.
Here is an example of a scenario from the Minesweeper game:
As you can see I use a DocString in the Given to express more visually the representation of the cells.
It works well, but if I try to use autoBindSteps, doesn't find the related functions.
If I remove the DocString with a simple string, like this:
The autoBindSteps works well.
I think I am either doing something wrong, or there is some kind of issue in the code.
Can someone help me with this?
Thanks in advance!
The text was updated successfully, but these errors were encountered: